impulse response for difference equation
조회 수: 38 (최근 30일)
이전 댓글 표시
I'm trying to derive the impulse response for the following:
y[n] = ay[n − 1] + x[n] − (a^N)x[n − N]
I am using two different methods.
- using the filter() function in Matlab.
- using pencil and paper, as per Exercise 2.25 in DTSP by Oppenheim
But the results don't agree with each other:
My code:
close all
clear
% solve the following:
% y[n] = ay[n − 1] + x[n] − (a^N)x[n − N]
% first with the fitler() function
% next with direct calculation of h(n), as per ex. 2.25 in the textbook
% using the filter() function
a=0.8;
N=5;
aa=zeros(1,50);
aa(1:2)=[1 -a];
bb=zeros(1,50);
bb(1)=1;
bb(N+1)=power(a,N);
myImpulse=zeros(1,50);
myImpulse(1)=1;
myImpulseResponse=filter(bb,aa,myImpulse);
t=0:49;
figure(1);
subplot(2,1,1)
stem(t,myImpulseResponse)
title('using filter()');
% next with direct calculation of h(n), as per ex. 2.25 in DTSP Oppenheim
% h[n] = (a^n)u[n] - (a^(n))*u[n-N]
a1 = power(a,t);
a2 = power(a,t);
a2(1:N)=0;
calculatedImpulseResponse = a1-a2;
subplot(2,1,2)
stem(t,calculatedImpulseResponse)
title('calculated as per DTSP Oppenheim')
I can explain my derivation (as per the example 2.25 in DTSP) if you need it.
I would like to know if I am using filter() correctly. Any observations would be appreciated.
댓글 수: 0
채택된 답변
David Goodmanson
2020년 8월 1일
Hi Roger,
try
bb(N+1) = -power(a,N);
which is what you actually have. I think you'll lilke the resulting plot.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Hamming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!