Wednesday, November 18, 2009

Program for generating basic functions. Unit Imupulse

CODE

clc
clear all
close all
n=6;


%To Generate Unit Impulse Siganl%
x=-2:1:2;
y=[zeros(1,2),ones(1),zeros(1,2)];
subplot(2,2,1);stem(x,y);
ylabel('Amplitude---->');
xlabel('n---->');
title('Unit Impulse Signal');


%To Generate Unit Step Signal%
t=0:1:n-1;
y1=ones(1,n);
subplot(2,2,2);stem(t,y1);
ylabel('Amplitude---->');
xlabel('n---->');
title('Unit Step Signal');


%To Generate Ramp Signal%
t1=0:1:n;
subplot(2,2,3);stem(t1,t1);
ylabel('Amplitude---->');
xlabel('n---->');
title('Ramp Sequence');


%To Generate Exponentional Sequence%
y2=exp(-1*t1);
subplot(2,2,4);stem(t1,y2);
ylabel('Amplitude---->');
xlabel('n---->');
title('Exponentional Sequence');



%To Generate Sine Sequence%
pause
t2=0:0.01:pi;
y3=sin(2*pi*t2);figure(2);
subplot(2,1,1);plot(t2,y3);
ylabel('Amplitude---->');
xlabel('n---->');
title('Sine Sequence');

%To Generate Cose Sequence%
t2=0:0.01:pi;
y3=cos(2*pi*t2);
subplot(2,1,2);plot(t2,y3);
ylabel('Amplitude---->');
xlabel('n---->');
title('Cose Sequence');

No comments:

Post a Comment