Need help, How do filter function work?
Show older comments
y[n] − 0.4y[n − 1] = x[n]; y[−1] = 1.
Need response to input signal, x[n] = ((0.4)^n)u[n] to n = −5, ..., 30.
2 Comments
William Rose
on 20 Jan 2018
Mr. Faria, You state that y is known at time n=-1, but you also say you want to see the system response to a signal which starts at n=-5. That leaves me unsure about whether you want to know y starting at time n=-5 or starting at time n=0. The Z transform of the system is Y(z)=H(z)*X(z), where H(z)=B(z)/A(z), where B and A are the numerator and denominator polynomials (polynomials in z^-1). In this case, the numerator polynomial is B=1, and the denominator polynomial is A=1-0.4*z^-1. Therefore the vector of numerator coefficients is b=1 and the vector of denominator coefficients is a=[1,-0.4]. If we ignore the bit about initial conditions on y (which means we assume y=0 at times in the past, then we can compute y at times from -5 to +30 using the filter function, as follows:
n=[-5:30];
ustep=(n>=0);
x=ustep.*0.4.^n;
a=[1 -.4];b=1;
y=filter(b,a,x);
plot(n,x,'ro-',n,y,'bx-');
xlabel('Time'); legend('X','Y');
You could get the same result for y using a for loop. I will call it y2 this time:
y2(1)=0;
for i=2:36,y2(i)=.4*y2(i-1)+x(i); end
The solution above started at n=-5 and did not obey the required initial condition y(-1)=1. If we want to apply the initial condition at n=-1, then we will use Matlab's filter to compute the output starting at time n=0. No time for more now. Maybe later.
Accepted Answer
More Answers (0)
Categories
Find more on Pole and Zero Locations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!