You are on page 1of 2

Lab2Aim- Write a program to generate following signala-Sinc Function

b-Rectangular Pulse
c-Triangular Pulse
d- Signum Function
Program% To plot a Sinc Function
clear all
t= -20:0.01:20;
x1=sinc(t);
subplot(2,2,1),plot(t,x1)
xlabel('\itt'),ylabel('x1({\itt})')
axis([-20 20 -1.5 1.5])
text(0,1,' \leftarrow Peak','FontSize',18)
% To plot a rectangular pulse
clear all
t=-20:0.01:20
X2=rectpuls(t/10)
subplot(2,2,2),plot(t,X2)
xlabel('\it t'),ylabel('X2({\itt})')
axis([-20 20 -1.5 1.5])
% To plot a triangular pulse
clear all
t=-20:0.01:20
X3=tripuls(t/10)
subplot(2,2,3),plot(t,X3)
xlabel('\it t'),ylabel('X3({\itt})')
%text(0,1,' \leftarrow Peak','FontSize',18)
axis([-20 20 -1.5 1.5])
% To plot a signum Function
clear all
t=-20:0.01:20
X4=sign(t/5)
subplot(2,2,4),plot(t,X4)
xlabel('\it t'),ylabel('X4({\itt})')
axis([-20 20 -1.5 1.5])

OUTPUT1.5

1.5

Ans a

Peak

Ans b

1
0.5
X2(t)

x1(t)

0.5
0
-0.5

-0.5

-1

-1

-1.5
-20

-15

-10

-5

0
t

10

15

-1.5
-20

20

1.5
Ans c

Ans d

-10

-5

0
t

10

15

20

-15

-10

-5

0
t

10

15

20

1
0.5
X4(t)

0.5
0

-0.5

-0.5

-1

-1

-1.5
-20

-15

1.5

X3(t)

-15

-10

-5

0
t

10

15

20

-1.5
-20

You might also like