Experiment 1 Basic Signal
Experiment 1 Basic Signal
AIM : To Generate continuous time and Discrete time sinusoidal signal, cosine signal.
Requirements : Computer with MATLAB software
Figure1.1
In figure 1.1 t= 0:0.01:2 , It shows that curve stars from zero and end at 2 with values at interval of
0.01
The time period and amplitude of the generated sine wave can be changed by changing the
corresponding parameters as shown in figure 1.2.
Figure 1.2
In figure 1.2, t=0:0.05:4 It shows that curve stars from zero and end at 4 with values at interval of
0.05
% Program for generation of discrete time sinusoidal signal. (Results – Figure 1.3.)
n = 0:0.05 :2 ; % sample index from 0 to 2
x = sin(2*pi*n); % Evaluate sin(0.2 *pi*n)
y=stem(n,x,'b','filled'); % Stem-plot with handle y
set(y,'markersize',4); % Change circle size
xlabel('n'); ylabel('x(n)'); % Label axis
title('discrete time plot of sin 2\pin'); % Title plot
Figure1.3.
MATLAB provides an ability to display more than one graph in the same figure window. By means of
the hold on command, several graphs can be plotted on the same set of axes. The hold off command
stops the simultaneous plotting. The following MATLAB fragment (Figure 1.4) displays graphs in
Figures 1.1 and 1.3 as one plot, depicting a “sampling” operation that we will study later.
% Program for generation of continuous and discrete time sinusoidal signal simultaneously.
t=0:0.05:2;
x= sin(2*pi*t);
plot(t,x,'b');
hold on
n=0:0.05:2;
x=sin(2*pi*n);
y=stem(n,x,'b','filled');
set(y,'markersize',4);
xlabel('t/n');
ylabel('x(t)/x(n)');
title('simultaneous plot of sin(2\pit)and its samples');
Figure1.4
Another approach is to use the subplot command, which displays several graphs in each individual
set of axes arranged in a grid, using the parameters in the subplot command. The following fragment
(Figure 1.5) displays graphs in Figure 1.1 and 1.3 as two separate plots in two rows. ...
% Program for simultaneous generation of continuous and discrete time sinusoidal signal. (Results
– figure 1.5)
t=0:0.05:2;
x= sin(2*pi*t);
subplot(2,1,1);
plot(t,x,'b');
xlabel('t in sec');
ylabel('x(t)');
title(' continuous time Plot of sin(2\pit)');
n=0:0.05:2;
x=sin(2*pi*n);
subplot(2,1,2);
y=stem(n,x,'b','filled');
set(y,'markersize',4);
xlabel('n');
ylabel('x(n)');
title('discrete time plot of sin2\pit');
Figure 1.5.
% Generation of continuous time cosine wave (Figure 1.6.)
t=0:0.05:2;
x=cos(2*pi*t);
plot(t,x,'b');
xlabel('t in sec');
ylabel('x(t)');
title('continuous time plot of cos(2\pit)');
Figure 1.6.
n=0:0.05:2;
x=cos(2*pi*n);
y= stem(t,x,'b',’filled’);
set(‘y,’ markersize’,4’)
xlabel('n');
ylabel('x(n)');
title('plot of discrete time cos(2\pin)');
Figure 1.7.