Professional Documents
Culture Documents
Find the rest of the sequence for 0 < n < 100 and plot it using the MATLAB
function stem.
CODE:
n = 0:99;
x = 0:99;
j = n+1;
x0 = 0;
x1 = 1;
x2 = 2;
for i = j
if i == 1
x(i) = x0;
elseif i == 2
x(i) = x1;
elseif i == 3
x(i) = x2;
else
x(i) = x(i-1) + x(i-3);
end
end
figure(1)
stem(n,x)
CODE:
n = -5:200;
x = n;
for i = 1:length(n)
if (n(i)< 0)
u(i) = 0;
else
u(i) = 1;
end
end
for i = 1: length(n)
x(i) = 0.5^(n(i))*u(i);
end
figure(2)
stem(n,x)
title('Plot of x[n] vs n')
xlabel('n')
ylabel('x[n]')
syms k n a
Energy = symsum(0.5^n,n,0,inf)