Need help, How do filter function work?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Miguel Faria
le 20 Jan 2018
Commenté : William Rose
le 22 Jan 2018
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 commentaires
William Rose
le 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.
Réponse acceptée
Miguel Faria
le 21 Jan 2018
1 commentaire
William Rose
le 22 Jan 2018
I assume that by u(n) you mean the unit step function: u=0 for n<0, u=1 for n>=0. I did give you x(n) in the code I posted earlier. I wrote:
n=[-5:30]; %vector of times
ustep=(n>=30); %boolean vector with 5 false values
%followed by 31 true values
x=ustep.*0.4.^n; %element-wise multiply and
%element-wise power
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Pole and Zero Locations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!