Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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 ?

Akzeptierte Antwort

Star Strider
Star Strider am 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 Kommentare
Johan Johan
Johan Johan am 27 Jan. 2020
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 am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by