The precision of plot filter design function is different than plot just coefficients of the same function of filter
2 views (last 30 days)
Show older comments
Johan Johan
on 27 Jan 2020
Commented: Star Strider
on 27 Jan 2020
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 ?
0 Comments
Accepted Answer
Star Strider
on 27 Jan 2020
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 Comments
Star Strider
on 27 Jan 2020
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.
More Answers (0)
See Also
Categories
Find more on Filter Analysis 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!