Matlab program to generate sine ramp and square and their spectrum
%program to generate sine square ramp and their spectra
clc;close all;
clear all;
f=10;
t=0:0.001:0.5;
s=sin(2*pi*f*t);
subplot(3,1,1)
plot(t,s)
title('sine wave');
q=square(2*pi*50*t);
subplot(3,1,2)
plot(t,q)
axis([0 0.2 -1.2 1.2])
title('square wave')
subplot(3,1,3)
plot(t,t);
title('ramp wave');
figure(2)
subplot(3,1,1)
plot(abs(fft(s)));
title('sine wave spectrum')
subplot(3,1,2)
plot(abs(fft(q)));
title('square wave spectrum')
subplot(3,1,3)
plot(abs(fft(t)));
title('ramp wave spectrum')
Comments
Post a Comment