You are on page 1of 5

311517106111/ECE-3B/DSP LAB/EC8562/EX NO:01

GENERATION OF SIGNALS
AIM:
To generate the elementary discrete and continuous time sequences and to obtain their
waveforms using MATLAB.

RESOURCE REQUIRED:
Personal Computer
Matlab version 9.6

PROCEDURE:
 Select the MATLAB version 9.6 icon.
 Select File>>New>>.m file in Editor’s window.
 Enter the program to display the basic signals by defining their functions.
 Divide the plot into subplots to display all the required 17 plots in a single window.
 Save the program with the extension .m.
 Select Run icon.
 The waveforms will be displayed on the screen.

PROGRAM:
clearall;
closeall;

%DISCRETE IMPULSE
n=-5:5;
x=[zeros(1,5),ones(1,1),zeros(1,5)];
subplot(3,6,1);
stem(n,x);
xlabel('n');
ylabel('x');
title('discrete impulse');

%DISCRETE STEP
n=-5:5;
y=[zeros(1,5),ones(1,6)];
subplot(3,6,2);
stem(n,y);
xlabel('n');
ylabel('y');
title('discrete step');

%CONTINUOUS STEP
t=0:5;
y=[ones(1,6)];
subplot(3,6,3);
311517106111/ECE-3B/DSP LAB/EC8562/EX NO:01

plot(t,y);
xlabel('t');
ylabel('y');
title('continuous step');

%CONTINUOUS RAMP
t=0:3;
a=t;
subplot(3,6,4);
plot(t,a);
xlabel('t');
ylabel('a');
title('continuous ramp');

%DISCRETE RAMP
n=0:3;
a=n;
subplot(3,6,5);
stem(n,a);
xlabel('n');
ylabel('a');
title('discrete ramp');

%CONTINUOUS PARABOLIC
t=0:6;
c=power(t,2);
subplot(3,6,6);
plot(t,c);
xlabel('t');
ylabel('c');
title('continuous parabolic');

%DISCRETE PARABOLIC
n=0:6;
c=power(t,2);
subplot(3,6,7);
stem(n,c);
xlabel('n');
ylabel('c');
title('discrete parabolic');

%CONTINUOUS EXPONENTIAL
t=0:5;
d=exp(t);
subplot(3,6,8);
plot(t,d);
xlabel('t');
ylabel('d');
title('continuous exponential');
311517106111/ECE-3B/DSP LAB/EC8562/EX NO:01

%DISCRETE EXPONENTIAL
n=0:5;
d=exp(n);
subplot(3,6,9);
stem(n,d);
xlabel('n');
ylabel('d');
title('discrete exponential');

%CONTINUOUS SINC
t=-5:0.1:5;
e=sinc(t);
subplot(3,6,10);
plot(t,e);
xlabel('t');
ylabel('e');
title('continuous sinc');

%DISCRETE SINC
n=-5:0.1:5;
e=sinc(n);
subplot(3,6,11);
stem(n,e);
xlabel('n');
ylabel('e');
title('discrete sinc');

%CONTINUOUS SIN
t=-5:0.5:5;
f=sin(t);
subplot(3,6,12);
plot(t,f);
xlabel('t');
ylabel('f');
title('continuous sin');

%DISCRETE SIN
n=-5:0.5:5;
f=sin(n);
subplot(3,6,13);
stem(n,f);
xlabel('n');
ylabel('f');
title('discrete sin');

%CONTINUOUS COS
t=-5:0.5:5;
f=cos(t);
311517106111/ECE-3B/DSP LAB/EC8562/EX NO:01

subplot(3,6,14);
plot(t,f);
xlabel('t');
ylabel('f');
title('continuous cos');

%DISCRETE COS
n=-5:0.5:5;
f=cos(n);
subplot(3,6,15);
stem(n,f);
xlabel('n');
ylabel('f');
title('discrete cos');

%CONTINUOUS SQUARE
t=-5:0.5:5;
g=square(t);
subplot(3,6,16);
plot(t,g);
xlabel('t');
ylabel('g');
title('continuous square');

%DISCRETE SQUARE
n=-5:0.5:5;
g=square(n);
subplot(3,6,17);
stem(n,g);
xlabel('n');
ylabel('g');
title('discrete square');
311517106111/ECE-3B/DSP LAB/EC8562/EX NO:01

OUTPUT:

discrete impulse discrete step continuous step continuous ramp discrete ramp continuous parabolic
1 1 2 3 3 40

1.5 30
2 2
0.5 0.5 1 20

a
x

c
1 1
0.5 10

0 0 0 0 0 0
-5 0 5 -5 0 5 0 5 0 2 4 0 2 4 0 5 10
n n t t n t
discrete parabolic continuous exponential discrete exponential continuous sinc discrete sinc continuous sin
40 150 150 1 1 1

30 0.5
100 100 0.5 0.5
20 0
d

e
c

f
50 50 0 0
10 -0.5

0 0 0 -0.5 -0.5 -1
0 5 10 0 5 0 5 -5 0 5 -5 0 5 -5 0 5
n t n t n t
discrete sin continuous cos discrete cos continuous square discrete square
1 1 1 1 1

0.5 0.5 0.5 0.5 0.5

0 0 0 0 0
g

g
f

-0.5 -0.5 -0.5 -0.5 -0.5

-1 -1 -1 -1 -1
-5 0 5 -5 0 5 -5 0 5 -5 0 5 -5 0 5
n t n t n

RESULT:
Thus the generation of elementary discrete and continuous time sequences is perfomed and
their waveforms are obtained using MATLAB.

You might also like