The precision of plot filter design function is different than plot just coefficients of the same function of filter

1 次查看(过去 30 天)
I'm confused about plotting the design filter with the same precision ,for example i have this coefficients (i found it by using fir1(68,[.35,.65])):
bb= [0.0005
0
0.0010
0.0000
-0.0024
-0.0000
0.0020
-0.0000
0.0015
-0.0000
-0.0066
0.0000
0.0078
-0.0000
-0.0000
-0.0000
-0.0142
-0.0000
0.0220
-0.0000
-0.0093
0
-0.0232
-0.0000
0.0519
-0.0000
-0.0411
0.0000
-0.0305
-0.0000
0.1464
0.0000
-0.2551
0.0000
0.2995
0.0000
-0.2551
0.0000
0.1464
-0.0000
-0.0305
0.0000
-0.0411
-0.0000
0.0519
-0.0000
-0.0232
0
-0.0093
-0.0000
0.0220
-0.0000
-0.0142
-0.0000
-0.0000
-0.0000
0.0078
0.0000
-0.0066
-0.0000
0.0015
-0.0000
0.0020
-0.0000
-0.0024
0.0000
0.0010
0
0.0005];
%% plot
freqz(bb,1,512)
the design Fig01
if i use the same last funtion fir1 with same specification
b=fir1(68,[.35,.65])';
freqz(b,1,512)
the design in Fig02
Why the Fig1 don't like the Fig2 in stop band ,why don't find the same precision ?

采纳的回答

Star Strider
Star Strider 2020-1-27
To reproduce the posted results, plot them as:
b = fir1(68,[.35,.65]);
bb = round(b, 4);
figure
freqz(bb,1,512);
figure
freqz(b',1,512)
In plotting ‘bb’, note that the coefficients have significantly reduced precision. Rounding (or truncating) the coefficients significantly affects the plotted filter frequency response.
  2 个评论
Johan Johan
Johan Johan 2020-1-27
Thank you, but i found this error
Error using round
Too many input arguments.
Does it the same idea with
b = fir1(68,[.35,.65]);
n=4;
bb = round(b*10^n)/10^n;
Star Strider
Star Strider 2020-1-27
As always, my pleasure!
Yes.
That should work.
I created my own version a few years ago:
roundn = @(x,n) round(x .* 10.^n)./10.^n; % Round ‘x’ To ‘n’ Digits, Emulates Latest ‘round’ Function
I do not now remember when the new round was introduced, although I believe it was R2016b, since many similar upgrades occurred them.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Digital Filter Analysis 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by