Académique Documents
Professionnel Documents
Culture Documents
Task 3a
clc; clear all; close all;
%-----------Rectangular function-----------
t = -2 : 0.01 : 2;
x = zeros(size(t));
T=1; %define length (time) of magnitude 1
for i = 1 : length(t)
if abs(t(i)) <= T/3
x(i) = 2;
else
x(i) = 0;
end
end
figure;
subplot(3,1,1); plot(t,x,'LineWidth',2);
ylim([0 3])
xlabel('t (sec)');
ylabel('x(t)');
title('Rectangular Function');
%-------------To plot Fourier transform------------
omega = [-60: 0.01 :60];
F = zeros(size(omega));
for k = 1 : length(omega)
F(k) = trapz(t,x.*exp(-j*omega(k)*t)); %Fourier Transform
Formula
end
F_Magnitude = abs(F); %Magnitude of the Fourier Transform
subplot(3,1,2); plot(omega,F_Magnitude,'LineWidth',2);
ylim([0 T*1.5])
xlabel('\omega (rad/sec)');
ylabel('|F(j\omega)|');
title('Fourier Transform of Rectangular');
%-------------Fourier plot graph |T*(sinc(w*(T/2)))|----------
y = zeros(size(omega));
a= T/3*3/T; % scaling factor
for k = 1 : length(omega)
y(k)= T*1/abs(a)*sinc(omega(k)*T/(a*2*pi));
y1(k)=abs(y(k));
end
subplot(3,1,3); plot(omega,y1,'LineWidth',2);
ylim([0 T*1.5])
xlabel('\omega (rad/sec)');
ylabel('|F(\omega)|');
title('Graph of T sinc(wT/3)');
Waveform for signal 3a
Task 3b