blob: 9347388a49f8bd65d6fd8d733c37dade6b76a307 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/usr/bin/env bash
### hamming.sh
# Convolve input vector with 3-element Hamming window [0.23, 0.54, 0.23]
# note: bash built-in $(( )) construct only supports integer arithmetic
# floating point operations will require a calculator or another language
# such as awk, perl, python, etc.
### input vector as array
X=($1)
echo ${#X[@]}
### Hamming window vector
H=(0.23 0.54 0.23)
echo ${#H[@]}
### length of output
L=$(( ${#X[@]} + ${#H[@]} - 1 ))
### iterate over both vectors
for N in $( seq 0 1 $L ) ; do
for M in $( seq 0 1 $(( ${#H[@]} - 1 )) ) ; do
if [ $(( $N >= $M )) ] ; then
printf "N=$N\tM=$M\tN-M=$(( $N - $M ))\n"
else
continue
fi
done
done
|