MATLAB: Butter filter

butter filterMATLAB

hi
suppose there are three signal like this
syms t x
a=2*sin(2*pi*t*300)
b=2*sin(2*pi*t*600)
c=2*sin(2*pi*t*900)
i I'll pass the frequency of 900 with butter filter
and my script is
syms t x
a=2*sin(2*pi*t*300)
b=2*sin(2*pi*t*600)
c=2*sin(2*pi*t*900)
z=a+b+c
[z,a]=butter(3,90/100)
fvtool(z,a)
where is the problem ?
please help

Best Answer

If you want to pass 900 Hz and reject the other frequencies, you need a highpass filter. You have designed a lowpass filter. Why are you using symbolic variables? And we need to know your sampling frequency in order to design a useful filter.
In this example, I'll assume that the sampling rate is 10 kHz.
Fs = 1e4;
[b,a] = butter(15,(2*650)/1e4,'high');
t = 0:1/Fs:1;
x = 2*sin(2*pi*t'*[300 600 900]);
x = sum(x,2);
% view your filter's magnitude response
fvtool(b,a,'Fs',Fs);
% filter the data
output = filter(b,a,x);
Although with such a stringent filtering problem, I think you're better off using fdesign.highpass.
d = fdesign.highpass('Fst,Fp,Ast,Ap',650,700,80,0.5,Fs);
Hd = design(d,'butter');
output = filter(Hd,x);
I think you see the above filter removes all but the 900 Hz component.
Related Question