Graphics Programs Reference
In-Depth Information
function filter ,
b9 = ones(1,11)/11;
m9 = length(b9);
y9 = filter(b9,1,x9);
y9= y9(1+(m9-1)/2:end-(m9-1)/2,1);
y9(end+1:end+m9-1,1)=zeros(m9-1,1);
The output is again in phase with the input, but the amplitude is dramatically
reduced as compared to the input.
plot(t,x9,t,y9)
1-max(y9(40:60))/2
ans =
0.6768
The running mean over eleven elements reduces the amplitude of this sig-
nal by 67%. More generally, the fi lter response obviously depends on the
frequency of the input. The frequency components of a more complex sig-
nal containing multiple periodicities. Hence, they are affected in a different
way. The frequency response of a fi lter
clear
b10 = ones(1,11)/11;
can be computed using the function freqz .
[h,w] = freqz(b10,1,512);
The function freqz returns the complex frequency response h of the digital
fi lter b10 . The frequency axis is normalized to . We transform the fre-
quency axis to the true frequency values by
f= w/(2*pi);
Next we calculate the magnitude of the frequency response and plot the
magnitude over the frequency.
magnitude = abs(h);
plot(f,magnitude)
xlabel('Frequency'), ylabel('Magnitude')
title('Magnitude')
This plot can be used to predict the magnitude of the fi lter for any frequency
Search WWH ::




Custom Search