I am working on this problem: Given an impulse response,
- find the system function,
- find the difference equation representation,
- find pole-zero plot,
- find output $y[n]$ if the input is $x[n] = 0.25^n * u[n]$
Here is what I have so far (MATLAB code)
Find H(z) $$H(z) = \frac{5}{1 - 0.25z^{-1}}\quad,\qquad|z| > 0.25$$
For part 2 I used the fact that $$H(z)=\frac{Y(z)}{X(z)}$$ I cross multiplied, then took the inverse $\mathcal Z$ transform and got: $$y[n] - 0.25y[n] = 5x[n]$$
For part 3 I used the
zplane
function:b = [5 0]; a = [1 -0.25]; figure; zplane(b,a);
Part 4 is where I am getting confused. I took the one-sided $\mathcal Z$-transform of the difference equation to get $$Y^+(z)-0.25[y[-1]+z^{-1}Y^+(z)] = 5X^+(z)$$ Assuming the system is casual (due to unit-step function in impulse response and input $x[n]$, also no initial conditions given in the problem), $$y[-1] = 0$$ So, after rearranging, $$Y^+(z)=\frac{5}{1-0.5z^{-1}+0.0625z^{-2}}\quad, \qquad |z| > 0.25$$ Using the
residuez
function for partial fraction decompb1 = [5 0 0]; a1 = [1 -0.5 0.0625]; [R p C] = residuez(b1,a1)
R = 0 5 p = 0.2500 0.2500 C = 0
Then taking the inverse $\mathcal Z$-transform of the terms generated by residuez
,
$$y[n] = 5(1/4)^nu[n]$$
However, when I check, this is not the case. For the check, I first create a MATLAB generated $y[n]$ sequence using filter
%MATLAB check for part 4 n = 0:50; % compare first 50 samples x = (1/4).^n; y = filter(b,a,x);
Then, create my check sequence calculated from the inverse $\mathcal Z$-transform and the residuez
function
ycheck = 5*(0.25).^n; error = max(abs(y-ycheck))
The sequences are not the same, and error nowhere close to nominal. Can anyone tell me where I went wrong please?