Step response and Impulse response of IIR filter

조회 수: 17 (최근 30일)
Alex sinWave
Alex sinWave 2022년 5월 30일
편집: Paul 2022년 5월 31일
Hi,
I am trying to plot the Step response and Impulse response of an IIR filter but I really do not know how as I am not using the designfilt to generate the filter based on frequency-response specifications I am using it as shown in the below code:
[X,Fs] = audioread(filename); % reading the wav file
temp = Fs/2
Wp = 170/temp; Ws = 220/temp;
[n,Wn]= buttord(Wp, Ws, 4, 8); % getting the order
[z,p,k] = butter(n, Wn, 'low'); % IIR filter
[sos,g] = zp2sos(z, p, k);
y = filtfilt(sos, g, X); % signal after applying the filter
I applied the Step response and Impulse response in an FIR filter successfully as shown below:
h = fir1(100, 170/temp, 'low'); % FIR filter
% Impulse response of digital filter
impz(h)
% Step response of digital filter
stepz(h)
y = filter(h, 1, X);% signal after applying the filter
I can not do the same thing in the IIR filter. what should I do?
thanks in advance.

채택된 답변

Paul
Paul 2022년 5월 30일
편집: Paul 2022년 5월 31일
Hi Alex,
It would be helpful to know the value of temp. Absent that, it seem like
[hstep,tstep] = stepz(sos);
hstep = hstep*g;
[himp,timp] = impz(sos);
himp = himp*g;
should work.
  댓글 수: 2
Alex sinWave
Alex sinWave 2022년 5월 30일
I don't really understand what is the use of the hstep and himp as I just want the plots of the Impulse and Step response so would they be usfull in somethinf?
hstep = hstep*g;
himp = himp*g;
Paul
Paul 2022년 5월 30일
편집: Paul 2022년 5월 31일
Once we have hstep and himp, just plot them.
Fs = 4000; % just making something up
temp = Fs/2;
Wp = 170/temp; Ws = 220/temp;
[n,Wn] = buttord(Wp, Ws, 4, 8); % getting the order
[z,p,k] = butter(n, Wn, 'low'); % IIR filter
[sos,g] = zp2sos(z, p, k);
[hstep,nstep] = stepz(sos);
hstep = hstep*g;
figure
stem(nstep,hstep);
figure
[himp,nimp] = impz(sos);
himp = himp*g;
stem(nimp,himp)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Floating-Point to Fixed-Point Conversion에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by