Bandpass filter using firpmord
54 views (last 30 days)
Show older comments
Hello, So I have this bandpass filter with : 0 between 0 and 0.2*pi, 1 between 0.3*pi and 0.5*pi and 0 between 0.6*pi and pi. the passband ripple=0.01 and the stopband ripple=0.05 Sampling frequency=16kHz I have to use firpmord and I have no idea how to make the length of the f vector = 2*length(m)-2 Here is my code
m=[0 0 1 1 0 0]
f=[0 0.2*pi 0.3*pi 0.5*pi 0.6*pi pi]
dev=[0.05,0.05,0.01,0.01,0.05,0.05];
Fs=16000;
[n,fo,mo,w]=firpmord(f,m,dev,Fs)
1 Comment
Wei-Han Hsiao
on 31 Jul 2020
1. First, you need to know that m (or so-called a) denotes the number of bands.
That is, m = 3 in your case since you have two stopbands and one passband.
2. Second, f is the edge frequency vecor that inherently removes the starting and
end points. Thus, 0 and pi in your f are redundant and should be removed.
3. Third, dev corresponds to m. Hence, your dev should have only 3 elements.
4. Last, f and Fs should have the same units. Use either radians or Hz.
So, under Fs = 16000 Hz, your codes should be modified as follows.
Fs=16000;
m=[0 1 0];
f=[0.2*Fs/2 0.3*Fs/2 0.5*Fs/2 0.6*Fs/2];
dev=[0.05 0.01 0.05];
Fs=16000;
[n,fo,mo,w]=firpmord(f,m,dev,Fs);
h = firpm(n,fo,mo,w);
figure,freqz(h,1,1024,Fs);
Hope it helps! ^^
Answers (1)
See Also
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!