%demonstration of basic sequences

n=-20:1:20;		% discrete time index

% unit sample sequence
delta=zeros(1,41);
delta(21)=1;

stem(n,delta)
xlabel('n')
ylabel('\delta[n]')
title('unit sample sequence')

pause

% unit step sequence
u=zeros(1,41);
u(21:41)=1;

stem(n,u)
xlabel('n')
ylabel('u[n]')
title('unit step sequence')

pause
 
% exponential sequence ( A positive, 0<alpha<1)
A=0.5;
alpha=0.9 ;
x=A*alpha.^n;

stem(n,x)
xlabel('n')
ylabel('x[n]')
title(['exponential sequence x[n]=A*\alpha^n with A=',num2str(A),',\alpha=',num2str(alpha)])

pause
 
% exponential sequence ( A positive, -1<alpha<0)
A=0.5;
alpha=-0.9;  
x=A*alpha.^n;

stem(n,x)
xlabel('n')
ylabel('x[n]')
title(['exponential sequence x[n]=A*\alpha^n with A=',num2str(A),', \alpha=',num2str(alpha)])

pause
 
% exponential sequence ( A positive, |alpha|>1)
A=0.5;
alpha=1.1;  
x=A*alpha.^n;

stem(n,x)
xlabel('n')
ylabel('x[n]')
title(['exponential sequence x[n]=A*\alpha^n with A=',num2str(A),', \alpha=',num2str(alpha)])

pause
 
% exponential sequence ( A positive, |alpha|>1)
A=0.5;
alpha=-1.1;  
x=A*alpha.^n;

stem(n,x)
xlabel('n')
ylabel('x[n]')
title(['exponential sequence x[n]=A*\alpha^n with A=',num2str(A),', \alpha=',num2str(alpha)])

pause
 
% sinusoidal sequence 
omega_0=0.1*pi;  
phi=0;
x=cos(omega_0*n+phi);
stem(n,x)
xlabel('n')
ylabel('x[n]')
title(['sinusoidal sequence x[n]=cos(\omega_0*n+\phi) with \omega_0=',num2str(omega_0),', \phi=',num2str(phi)])

pause
 
% sinusoidal sequence 
omega_0=0.1*pi;  
phi=-pi/2;
x=cos(omega_0*n+phi);
stem(n,x)
xlabel('n')
ylabel('x[n]')
title(['sinusoidal sequence x[n]=cos(\omega_0*n+\phi) with \omega_0=',num2str(omega_0),', \phi=',num2str(phi)])

pause
  