Monday, July 21, 2014

GENERATION ON VARIOUS SIGNALS AND SEQUENCES



GENERATION ON VARIOUS SIGNALS AND SEQUENCES (PERIODIC AND APERIODIC), SUCH AS UNIT IMPULSE, UNIT STEP, SQUARE, SAWTOOTH, TRIANGULAR, SINUSOIDAL, RAMP, SINC .


// UNIT IMPULSE
close ;
clear all;
clc;
t=-5:1:5;
a=[zeros(1,5) 1 zeros(1,5)];
k=input('enter the amplitude');
b=k*a;
subplot(2,1,1);
plot2d(t,b);
xtitle('impulse response', 'amplitude’, 'time');
subplot(2,1,2);
plot2d3(t,b);
xtitle('impulse response', 'amplitude’, 'time');


OUTPUT:-







OUTPUT WAVEFORM:-



-------------------------------------------------------------------------------------------------------------------------

// STEP SEQUENCE
 
close ;
clear all;
clc;
t=-5:1:5;
a=4*[zeros(1,5) ones(1,6)];
plot2d3(t,a);
xtitle('step response', 'amplitude’, 'time');
                                                                        
OUTPUT WAVEFORM:
 


--------------------------------------------------------------------------------------------------------------------------

// RAMP WAVEFORM

close ;
clear all;
clc;
t=0:1:50;
for n=0:50;
    x(n+1)=n;
end
plot2d(t,x);
xtitle('step response', 'amplitude’, 'time');
 
 
OUTPUT  WAVEFORM:
 


 -------------------------------------------------------------------------------------------------------------------------

//SAWTOOTH WAVEFORM


close ;
clear all;
clc;
p=100;
t=1:1:p*10;
for n=1:(p/2)
 a(n)=n;
end
for n=(p/2)+1:p
    a(n)=n-p;
end
a1=a
for i=1:9
    a1=[a1 a];
end
plot2d(t,a1);
axis( [ 0 1000 -100 100]);
xtitle('sawtooth sequence', 'amplitude’, 'time');
 
OUTPUT  WAVEFORM:
 

 -------------------------------------------------------------------------------------------------------------------------

//SQUARE WAVEFORM

 
close ;
clear all;
clc;
t=(0:0.1:5*%pi)';
plot2d1(1.5*%pi*squarewave(t))
xtitle('square wave','time','amplitude');
 
 
OUTPUT   WAVEFORM:-



 -----------------------------------------------------------------------------------------------------------------------

// TRIANGULAR WAVEFORM

 
close ;
clear all;
clc;
for n=0:6
for a=1:5
x(n*8+a)=a
end
for i=1:4;
a=a+1;
x(n*8+a)=5-i
end
end
xtitle(' triangular wave form ','time','amplitude');


----------------------------------------------------------------------------------------------------------------------------

//SINE AND COSINE WAVES

close ;
clear all;
clc;
n=0:0.1:2*%pi;
x=sin(n);
subplot(211);
plot2d(n,x);
xtitle('sine wave', 'time','amplitude');
y=cos(n);
subplot(212);
plot2d(n,y);
xtitle('cos wave', 'time','amplitude');
 
OUTPUT   WAVEFORM:

 ------------------------------------------------------------------------------------------------------------------------

//SINC FUNCTION

close ;
clear all;
clc;
t=-20:0.01:20;
x=sinc(t);
subplot(211);
plot2d(t,x);
xtitle('sinc waveform','time','amplitude');

OUTPUT  WAVEFORM :