You are on page 1of 2

MATLAB CODE:

close all;
clear all;
clc;

a=zeros(1,10);
b=ones(1,10);
x=[a a b b b b a a];
%%%% rectangular pulse %%%%
t1=-40:1:39;
subplot(2,2,1);
plot(t1,x);
xlabel('Time');
ylabel('Amplitude');
title('Plot of rectangular pulse');

%%%% DFT of the above pulse %%%%
f1=-pi:pi/128:(pi-pi/128);
y=fftshift(fft(x,256));
subplot(2,2,2);
plot(f1,abs(y));
xlabel('Frequency');
ylabel('Amplitude');
title('Plot of sinc pulse');

%%%% Phase versus frequency plot %%%%
subplot(2,2,3);
plot(f1,phase(y));
xlabel('Frequency');
ylabel('Phase');
title('Phase versus frequency plot');

You might also like