Sei sulla pagina 1di 9

Generation of signals

Aim:
To generate various types of signals using MATLAB 7.1

Apparatus required: Personal computer MATLAB 7.1 Algorithm:


Impulse invariance: Initialize the time period as t=-10:10 Obtain the impulse signal by using zeros (1,m) & ones (1,n) , x=[zeros(1,10), ones(1,1), zeros(1,10)] Plot the continuous time and discrete time signal Step invariance: Initialize the time period as t=-10:10 Obtain the step signal by using zeros (1,m) & ones (1,n) , x=[zeros(1,10), ones(1,1), zeros(1,10)] Plot the continuous time and discrete time signal Ramp signal: Initialize the time period as t=-10:10 Obtain the ramp signal by using the expression r(t)=t ,t 0 =0 ,t < 0

Plot the continuous time and discrete time signal

Exponential signal: Initialize the time period as t=-10:10 Obtain the exponential signal by using the expression X(t)=exp(t) Plot the continuous time and discrete time signal Sinusoidal signal: Initialize the time period as t=-: Obtain the sine signal by using the expression X(t)=sin(t) Plot the continuous time and discrete time signal Cosine signal: Initialize the time period as t=-: Obtain the sine signal by using the expression X(t)=sin(t) Plot the continuous time and discrete time signal Triangular pulse: Initialize the time period as t=-5:5 and T=5 Obtain the triangular pulse by using the expression F(t)= [1-t/T] , t T =0 ,elsewhere

and obtain command is y=tripuls(t,T) Plot the continuous time and discrete time signal

Rectangular pulse: Initialize the time period as t=-5:5 and T=5 Obtain the rectangular pulse by using the expression F(t)= 1 , tT = 0 , otherwise and the command is y=rectpuls(t,T) Plot the continuous and discrete time signal Sinc pulse: Initialize the time period as t=linspace(-5,5) Obtain the sinc pulse by using the expression Y(t)= sinc(t) Plot the continuous and discrete time signal Sawtooth pulse: Initialize the time period as t=-5:5 , T=5 & x=1 Obtain the sawtooth waveform by using the command Y=tripulse(t,T,x) Plot the continuous and discrete time signal

Signum function: Initialize the time period as t=-5:5 Obtain the signum signal by using the expression Sign(t)= -1 ,t<0 = 0 ,t=0 =1 ,t>0 and the command is y=sign(t) Plot the continuous and discrete time signal

Program:
n=-5:5; a=0:5; b=0:5; x=linspace(-5,5); imp=[zeros(1,5),ones(1,1),zeros(1,5)]; step=(zeros(1,5),ones(1,6)]; c=sinc(x); d=sin(x); e=cos(x); f=sawtooth(n,0.01); g=exp(x); h=sign(x); i=rectpuls(x); j=tripuls(x); figure;subplot(4,3,1);plot(n,imp);xlabel(time);ylabel(amp); title(impulse); subplot(4,3,2);plot(n,step);xlabel(time);ylabel(amp); title(step); subplot(4,3,3);plot(b,a);xlabel(time);ylabel(amp); title(ramp); subplot(4,3,4);plot(x,c);xlabel(time);ylabel(amp); title(sinc); subplot(4,3,5);plot(x,d);xlabel(time);ylabel(amp); title(sin);

subplot(4,3,6);plot(x,e);xlabel(time);ylabel(amp); title(cos); subplot(4,3,7);plot(x,f);xlabel(time);ylabel(amp); title(sawtooth); subplot(4,3,8);plot(x,g);xlabel(time);ylabel(amp); title(exponential); subplot(4,3,9);plot(x,h);xlabel(time);ylabel(amp); title(sign); subplot(4,3,10);plot(x,i);xlabel(time);ylabel(amp); title(rectpuls); subplot(4,3,11);plot(x,j);xlabel(time);ylabel(amp); title(tripuls);

Output:
impulse 1
amp amp

step 1 0.5 0 -5
amp

ramp 5

0.5 0 -5

0 time sinc

0 time sin

2 time cos

1
amp amp

1 0 -1 -5
amp

1 0 -1 -5

0 -1 -5

0 time sawtooth

0 time exponential

0 time sign

1
amp amp

200 100 0 -5
amp

1 0 -1 -5

0 -1 -5

0 time rectpuls

0 time tripuls

0 time

1
amp

1
amp

0.5 0 -5

0.5 0 -5

0 time

0 time

Result:
Thus the various types of signals were generated and the output were verified

Potrebbero piacerti anche