% DRAWING SIGNALS WITH MATLAB 
% Author C. Prati
% February 17, 2020
clear
close all

%--------------------------------------------------
% 1
% Let us generate a discrete cosinusoidal signal x with
% frequency of fo=40Hz, N=100 samples using a sampling interval
% T=1/1000 second

N=1000;
fo=40;
T=1/10000;
t=(0:N-1)*T;
x=cos(2*pi*fo*t);

%----------------------------------------------------
% 2
% Let us plot the discrete signal x in figure 1
% as a sequence of samples ... from 0 to N-1
figure(1)
stem((0:N-1),x)
xlabel('samples')
ylabel('amplitude')
title('The sequence x')
pause
% as a sequence on samples along a time axis t
figure(2)
stem(t,x)
xlabel('time (seconds)')
ylabel('amplitude')
title('The discrete time signal x')
pause
% as a continuous line connecting the samples 
figure(3)
plot(t,x)
xlabel('time (seconds)')
ylabel('amplitude')
title('The "continuous" time signal x')
pause
% as a continuos line superimposed to samples
figure(4)
plot(t,x,'b')
xlabel('time (seconds)')
ylabel('amplitude')
title('The "continuous" time signal x + samples')
hold on
stem(t,x,'r','filled')
hold off