How do you find Error response in Parks-McClellan algorithm
7 views (last 30 days)
Show older comments
This is the code for a parks-McClellan, I used custom function so everything is correct
My question is how to get Error response like above? Thank you!
wp = 0.2*pi; ws = 0.3*pi; Rp = 0.25; As = 50;
[delta1,delta2] = db2delta(Rp,As);
[N,f,m,weights] = firpmord([wp,ws]/pi,[1,0],[delta1,delta2]);
h = firpm(N,f,m,weights);
[db,mag,pha,grd,w] = freqz_m(h,[1])
delta_w = 2*pi/1000; wsi=ws/delta_w+1; wpi = wp/delta_w;
Asd = -max(db(wsi:1:501))
N = 46
h = firpm(N,f,m,weights);
[db,mag,pha,grd,w] = freqz_m(h,[1])
Asd = -max(db(wsi:1:501))
0 Comments
Answers (1)
Raunak Gupta
on 19 Nov 2019
Hi,
In the above code ‘mag’ is the response from the designed filter using the Park’s-McClellan algorithm. For Comparing this response to the ideal one you may need to create a signal which is ‘1’ between [0,0.2π] and ‘0’ between [0.3π,π]. Since the output of the filter has 501 evaluation points the same will be the format for ideal response. Following code will help plotting the error response.
ideal = zeros(1,501);
ideal(1,1:101) = 1;
Error = mag-ideal;
Error (101:151) = nan;
t=linspace(0,1,501);
plot(t, Error);
It is recommended to provide source for the helper functions used in the code such as db2delta , freqz_m as these are custom written functions.
0 Comments
See Also
Categories
Find more on 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!