figure(1)

%Plot of delta function
subplot(311)
n = -10:10;                     % Set range for plot
delta = (n==0);                 % Delta function - one when n equals zero
stem(n,delta);
axis([-10 10 -0.5 1.5])
hold on
plot([-10 10],[0 0])            % Put in zero axis
grid
ti = title('\delta(n)');
set(ti,'FontSize',16)           % Bigger font on title
set(gca,'XTickLabel',[]);       % Remove x axis labels from top plot

%Plot of step function
subplot(312)
u = (n>=0);                     % setp function - one when n >= 0
stem(n,u);
axis([-10 10 -0.5 1.5])
hold on
plot([-10 10],[0 0])            % Put in zero axis
grid
ti = title('u(n)');
set(ti,'FontSize',16)           % Bigger font on title
set(gca,'XTickLabel',[]);       % Remove x axis labels from top plot

%Plot of exponential
subplot(313)
y = (0.9).^n;                   % exponential function
stem(n,y);
axis([-10 10 -1 4])
hold on
plot([-10 10],[0 0])            % Put in zero axis
grid
ti = title('0.9^n');
set(ti,'FontSize',16)           % Bigger font on title

%-----------------------------------------------------------------------------%

figure(2)

% Continuous-time and Discrete-Time Sinusoids
subplot(311)
t = -20e-3:0.01e-3:20e-3;
W = 500;
ya = cos(W*t);
plot(t*1e3,ya);
axis([-20 20 -1.5 1.5])
hold on
plot([-20 20],[0 0]);
grid
xlabel('t (ms)')
yl = ylabel('y_a(t)')
set(yl,'FontSize',14);

subplot(312)
n = -20:20;
w = 0.5;
y = cos(w*n);
stem(n,y);
axis([-20 20 -1.5 1.5])
hold on
plot([-20 20],[0 0]);
grid
xlabel('n (sample number)')
yl = ylabel('y[n]');
set(yl,'FontSize',14);


subplot(313)
plot(t*1e3,ya);
axis([-20 20 -1.5 1.5])
hold on
stem(n,y,'r');
plot([-20 20],[0 0]);
grid

subplot(311)
ti = title('y_a(t) = cos(500 t);  y[n] = cos(0.5 n)');
set(ti,'FontSize',16);
%-----------------------------------------------------------------------------%

figure(3)

%Concept of Period for discrete-time sinusoid is different than
%for continuous-time sinusoid

subplot(211)
n=0:20;
w = 7*pi/8;
y = 5*cos(w*n);
stem(n,y)
hold on
axis([0 20 -7.5 7.5])
plot([0 20],[0 0]);
axis
grid
ti=title('y[n] = 5 cos(7 \pi/8 n)')
set(ti,'FontSize',16);

subplot(212)
t=0:0.01:20;
w=7*pi/8;
ya=5*cos(w*t);
plot(t,ya)
hold on
stem(n,y,'r')
axis([0 20 -7.5 7.5])
plot([0 20],[0 0]);
axis
grid
ti=title('y_a(t) = 5 cos(7\pi/8 t);  y[n] = 5 cos(7\pi/8 n)')
set(ti,'FontSize',16);
