Sunday, January 26, 2014

Matlab Program for Generation of Basic Signals

with 0 Comment
Maltab Program for Generation of Basic Signals like Unit Step Function,Unit Ramp Function,Unit Impulse Function,Sinusoidal Function,Cosine Signal,Exponential Signal Increasing,Exponential Signal Decreasing,Square Signal:

clc
clear all
close all
t=-1:0.1:1;
x=[0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1];
subplot(4,4,1);
plot(t,x,'k');
gridon
ylabel('amplitude');
xlabel('time');
title('Unit Step');
subplot(4,4,2);
stem(t,x,'k');
gridon
ylabel('amplitude');
xlabel('time');
title('Unit Step');

t=-1:0.1:1;
x=[0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0];
subplot(4,4,3);
plot(t,x,'k');
gridon
ylabel('amplitude');
xlabel('time');
title(' Unit Impulse');
subplot(4,4,4);
stem(t,x,'k');
gridon
ylabel('amplitude');
xlabel('time');
title(' Unit Impulse');

t=0:1:5;
x=[0,1,2,3,4,5];
subplot(4,4,5);
plot(t,x,'k');
gridon
axis([0 5 0 5]);
ylabel('amplitude');
xlabel('time');
title(' Unit Ramp');
subplot(4,4,6);
stem(t,x,'k');
gridon
axis([0 5 0 5]);
ylabel('amplitude');
xlabel('time');
title(' Unit Ramp');

t=-2*pi:pi/5:2*pi;
x=sin(t);
subplot(4,4,7);
plot(t,x,'k');
gridon
axis([-2*pi 2*pi -1 1])
ylabel('amplitude');
xlabel('time');
title(' Sine Signal');
subplot(4,4,8);
stem(t,x,'k');
gridon
axis([-2*pi 2*pi -1 1])
ylabel('amplitude');
xlabel('time');
title(' Sine Signal');

t=-6.28:0.5:6.28;
x=cos(t);
subplot(4,4,9);
plot(t,x,'k');
gridon
axis([-6.28 6.28 -1 1])
ylabel('amplitude');
xlabel('time');
title(' Cosine signal');
subplot(4,4,10);
stem(t,x,'k');
gridon
axis([-6.28 6.28 -1 1])
ylabel('amplitude');
xlabel('time');
title(' Cosine signal');

t=0:0.5:5;
x=exp(t);
subplot(4,4,11);
plot(t,x,'k');
gridon
axis([0 5 0 150]);
ylabel('amplitude');
xlabel('time');
title(' Exponential Signal Increasing');
subplot(4,4,12);
stem(t,x,'k');
gridon
axis([0 5 0 150]);
ylabel('amplitude');
xlabel('time');
title(' Exponential Signal Increasing');

t=0:0.5:5;
x=exp(-t);
subplot(4,4,13);
plot(t,x,'k');
gridon
axis([0 5 0 1]);
ylabel('amplitude');
xlabel('time');
title(' Exponential Signal Decreasing');
subplot(4,4,14);
stem(t,x,'k');
gridon
axis([0 5 0 1]);
ylabel('amplitude');
xlabel('time');
title(' Exponential Signal Decreasing');

t=-10:1:10;
x=square(t);
subplot(4,4,15);
plot(t,x,'k');
gridon
axis([-10 10 -1.5 1.5]);
ylabel('amplitude');
xlabel('time');
title(' Square Signal');
subplot(4,4,16);
stem(t,x,'k');
gridon
axis([-10 10 -1.5 1.5]);
ylabel('amplitude');
xlabel('time');
title(' Square Signal');

0 comments:

Post a Comment

Powered by Blogger.

Blog Archive