Saturday 21 July 2018

REPRESENTATION OF BASIC SIGNALS USING MATLAB

Sinusoidal Signal, Unit Impulse, Unit Step, Ramp, Sawtooth Wave Forms
Generate Sinusoidal signal



clear all;

close all;

clc;



N = input('Enter the number of cycles ...:: '); t = 0:0.05:N;



x = sin(2*pi*t);

subplot(1,2,1);

plot(t,x);



xlabel('---------> Time');

ylabel('---------> Amplitude');

title('Sinusoidal');



subplot(1,2,2);

stem(t,x);

xlabel('---------> Time');

ylabel('---------> Amplitude');

title('Sinusoidal');




OUTPUT



Enter the number of cycles ...:: 2




Generate Unit Impulse function



clear all;

close all;

clc;



x = ones(1,1);

y = zeros(1,2);

z = [y, x, y];

stem(z);

xlabel('---------> Time');

ylabel('---------> Amplitude');

title('Unit Impulse');


OUTPUT



Generate Unit Step function

clear all;
close all;
clc;

x = ones(100);

subplot(2,1,1);
plot(x);
xlabel('---------> Time');
ylabel('---------> Amplitude');
title('Step signal');

subplot(2,1,2);
stem(x);
xlabel('---------> Time');
ylabel('---------> Amplitude');


title('Step signal');




OUTPUT



Generate Ramp function



clear all; close all; clc;



t = 0:25;

y = t;



subplot(1,2,1);

plot(t,y);

xlabel('---------> Time');

ylabel('---------> Amplitude');

title('Ramp function');



subplot(1,2,2);

stem(t,y);

xlabel('---------> Time');

ylabel('---------> Amplitude');

title('Ramp function');



OUTPUT



Generate Sawtooth Waveform

clear all; close all; clc;

N = input('Enter the number of cycles ...:: ');

t1 = 0:25;
t = [];

for i = 1:N,
t = [t,t1];
end;

subplot(2,1,1);
plot(t);
xlabel('---------> Time');
ylabel('---------> Amplitude');
title('Sawtooth waveform');

subplot(2,1,2);
stem(t);
xlabel('---------> Time');
ylabel('---------> Amplitude');
title('Sawtooth waveform');


OUTPUT



Enter the number of cycles ...:: 3



% sine wave

t=0:0.01:1; a=2;
b=a*sin(2*pi*2*t);
subplot(3,3,1);

stem(t,b);
xlabel('time');
ylabel('Amplitude');
title ('sinewave');

% Cosine wave

t=0:0.01:1; a=2; b=a*cos(2*pi*2*t); subplot(3,3,2);

stem(t,b);
xlabel('time'); ylabel('Amplitude');
title ('Cos wave');
% Square wave

t=0:0.01:1; a=2; b=a*square(2*pi*2*t); subplot(3,3,3);

stem(t,b);
xlabel('time'); ylabel('Amplitude');
title ('square wave');
% Exponential waveform

t=0:0.01:1;
a=2;
b=a*exp(2*pi*2*t);
subplot(3,3,4);

stem(t,b);
xlabel('time');
ylabel('Amplitude');
title ('exponential wave');

% Sawtooth

t=0:0.01:1;
a=2;
b=a*sawtooth(2*pi*2*t);
subplot(3,3,5);
stem(t,b);
xlabel('time');
ylabel('Amplitude');
title ('sawtooth wave');
% Unit Step Signal

n=-5:5;
a = [zeros(1,5),ones(1,6)]; subplot(3,3,6); stem(n,a);

Xlabel ('time');
Ylabel ('amplitude'); title('Unit step');


% Unit Impulse

n=-5:5;
a = [zeros(1,5),ones(1,1),zeros(1,5)];
subplot(3,3,7);
stem(n,a);
Xlabel ('time');
Ylabel ('amplitude');
title('Unit impulse');



 



No comments:

Post a Comment