how can I find y[n]
5 views (last 30 days)
Show older comments
Bugrahan KISA
on 6 Mar 2018
Commented: Ship Chern Wei
on 21 Oct 2020
I want to find output of system y[n] for n = 1,2,3,4 , y[n] is equal to y[n]=0.5*y[n-1] + x[n] + 0.5*x[n-3] .I have a knowledge about this system , system is LTI .I don't know right the code that below.
n = [1:4];
x = cos(pi.*n).*[0 ones(1,3)];
x_shifted=[0 x(1:end-1)];
x_scaled=2.*x;
% stem(n,x)
y(3) = 0;
y2(3) = 0;
for k=4:length(x)
y(k) = 0.5*y(k-1) + x_shifted(k) +0.5*x_shifted(k-1)+0.5*x_shifted(k-3);
y2(k)=0.5*y(k-1) + x(k) + 0.5*x(k-3);
end
stem(n,y,'rx')
hold on
stem(n,y2,'b')
1 Comment
Accepted Answer
Abraham Boayue
on 7 Mar 2018
% write your equation as : y(n)-0.5y(n-1) = x(n)+0x(n-1)+0x(n-2)+0.5x(n-3)
% and define the coefficient vectors a and b as shown.
n = 1:4;
a = [1 -0.5];
b = [1 0 0 0.5];
x = cos(pi.*n).*[0 ones(1,3)];
y = filter(b,a,x); % output of the LTI system
stem(n,y,'linewidth',3,'color','m')
grid;
a = title('Output of an LTI System y(n)');
set(a,'fontsize',14);
a = ylabel('y(n)');
set(a,'Fontsize',14);
a = xlabel('n [1 4]');
set(a,'Fontsize',14);
% figure
% stem(n,x,'linewidth',3,'color','g')
3 Comments
More Answers (0)
See Also
Categories
Find more on Marine and Underwater Vehicles 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!