I want to design a simple Low pass filter with equiripple window function and cut off freq at 200 hz . Could somebody please help me how to design low pass filter for below code?
Show older comments
clc; clear all; close all; t=1:0.01:5; x=2*sin(1000*t)+2*sin(500*t); subplot(4,1,1); plot(t,x); fs=2000; nfft=length(x); f=(0:1/nfft:1-1/nfft)*fs; y=fft(x); subplot(4,1,2); plot(f,abs(y)); title('Freq Before filtering')
Answers (1)
Wayne King
on 30 Sep 2013
Edited: Wayne King
on 30 Sep 2013
When you say "equiripple window function" you are confusing two FIR filter design methods, the equiripple design, and the window method. I'll assume you want an equiripple design.
Also, you have a number of issues with your example above. Your sampling frequency is 100 Hz. Look at the time increment in your time vector, 0.01.
Then, you have frequencies of 1000/(2*pi) and 500/(2*pi), both of which are higher than the Nyquist frequency (50 Hz).
In my example, I'll assume you really want a cutoff of 200 Hz, so I'll increase your sampling rate to something that will actually allow that, 1000 Hz.
If you have the Signal Processing Toolbox:
t = 0:0.001:5;
x = 2*sin(2*pi*100*t)+sin(2*pi*300*t)+randn(size(t));
d = fdesign.lowpass('Fp,Fst,Ap,Ast',200,225,0.5,60,1000);
Hd = design(d,'equiripple');
y = filter(Hd,x);
Compare the PSD of y with that of x
subplot(211)
periodogram(x,[],length(x),1000);
subplot(212)
periodogram(y,[],length(x),1000);
Categories
Find more on Digital Filter Design in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!