How do you find Error response in Parks-McClellan algorithm
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Raunak Gupta
2019-11-19
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Filter Design 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!