Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Experiment 2

Aim: To obtain the response of various signals

Software required: MATLAB

Program code:

clc;
clear all;
close all;
f=2;
t=0:0.02:2;

%--------------------------------------sin wave-------------------
y1=sin(2*pi*f*t);
subplot(3,2,1);
plot(t,y1,'R','linewidth',2);
grid on;
xlabel('Time');
ylabel('Amplitude');
title('Sine waveform');

%------------------------------------cos wave---------------------
y2=cos(2*pi*f*t);
subplot(3,2,2);
plot(t,y2,'G','linewidth',2);
grid on;
xlabel('Time');
ylabel('Amplitude');
title('Cos waveform');

%----------------------------------ramp--------------------------
y3=t;
subplot(3,2,3);
plot(t,y3,'k','linewidth',2);
grid on;
xlabel('Time');
ylabel('Amplitude');
title('Ramp waveform');
%---------------------------------unit step---------------------------
y4=t>=0;
subplot(3,2,4);
plot(t,y4,'B','linewidth',2);
grid on;
xlabel('Time');
ylabel('Amplitude');
title('Step waveform');

%----------------------------------exponential---------------------------
y5=exp(0.5*t);
subplot(3,2,5);
plot(t,y5,'c','linewidth',2);
grid on;
xlabel('Time');
ylabel('Amplitude');
title('Exp waveform');

%-------------------------------------impulse--------------------
t1=-5:1:5
y6=[zeros(1,5),ones(1,1),zeros(1,5)];
subplot(3,2,6);
stem(t1,y6,'O','linewidth',2);
grid on;
xlabel('Time');
ylabel('Amplitude');
title('Impulse waveform');

Output: Waveforms of various signals is performed

You might also like