impulse response for difference equation
41 次查看(过去 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!