You are on page 1of 1

3.

Steady steate and Transient Response

n = -5:20;
x = (10 + 4*cos(pi/4*n+pi/8) + 3*cos(pi/3*n-pi/4)).*ustep(n,0);
y = filter([1 -1 1],1,x);
subplot(211)
stem(n,x,'filled')
grid
ylabel('x[n]')
subplot(212)
stem(n,y,'filled')
hold

stem(n,y,'filled')
grid
ylabel('y[n]')
xlabel('Sample Index n')

function x = ustep(n,n0)
% function x = ustep(n,n0)
%
% Generate a time shifted unit step sequence
x = zeros(size(n));
i_n0 = find(n >= n0);
x(i_n0) = ones(size(i_n0));
end

You might also like