Graphics Programs Reference
In-Depth Information
clear
t = (1:100)';
x8 = 2*sin(2*pi*t/20);
A running mean over eleven elements is designed and this fi lter is applied
to the input signal.
b8 = ones(1,11)/11;
m8 = length(b8);
y8 = filter(b8,1,x8);
The phase is corrected for causal indexing.
y8= y8(1+(m8-1)/2:end-(m8-1)/2,1);
y8(end+1:end+m8-1,1)=zeros(m8-1,1);
Both input and output of the fi lter are plotted.
plot(t,x8,t,y8)
The fi lter obviously reduces the amplitude of the sine wave. Whereas the
input signal has an amplitude of 2, the output has an amplitude of
max(y8)
ans =
1.1480
The fi lter reduces the amplitude of a sine with a period of 20 by
1-max(y8(40:60))/2
ans =
0.4260
i.e., approximately 43%. The elements 40 to 60 are used for computing the
maximum value of y8 in order to avoid edge effects. On the other hand, the
fi lter does not affect the phase of the sine wave, i.e., both input and output
are in phase.
The same fi lter, however, has a different impact on a different signal. Let
us design another sine wave with a similar amplitude, but with a different
period of 15.
clear
t = (1:100)';
x9 = 2*sin(2*pi*t/15);
Applying a similar fi lter and correcting the output for the phase shift of the
Search WWH ::




Custom Search