Step response and Impulse response of IIR filter
조회 수: 17 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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
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 Center 및 File Exchange에서 Floating-Point to Fixed-Point Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!