blob: fdd6ba6154178be6df8c957d3df480d3cad3cd9e (
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
|
#!/bin/bash
### hamming.sh
# Convolve input vector with 3-element Hamming window [0.23, 0.54, 0.23]
# note: bash built-in $(( )) constructs only support integer arithmetic
# floating point operation will require another language such as awk, perl, or
# python.
### 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
|