Вы находитесь на странице: 1из 7

UEC404

Signals and System


Lab
Abhinav Choudhary 101606003
Assignment -
Question Write a program in MATLAB to determine and plot the Fourier
transform of following signals:
1. x(t) = e-t u(t) and x(t) = e-2t u(t)

t=0:0.01:10;
k=0;
for f=-10:0.1:10
k=k+1;
y(k)=trapz(t,exp(-t*(1+1i*2*f*pi)));
end
f=-10:0.1:10;
%plot(f,y)
%subplot(2,1,1)
a=(1+(2*pi*f).^2).^-1;
%plot(f,a)
z=abs(y);
subplot(2,1,1)
plot(f,z)
b=0;
for f=-10:0.1:10
b=b+1;
q(b)=trapz(t,exp(-t*(2+1i*2*f*pi)));
end
f=-10:0.1:10;
w=abs(q);
subplot(2,1,2)
plot(f,w)

Output:
Question- Program to determine and plot continuous time Fourier transform
of rectangular pulse with using trapezoid function.
Theory: Trapezoid (trapz) is an approach for integration in MATLAB. =
trapz(Y) returns the approximate integral of Y via the trapezoidal method with
unit spacing.
Q = trapz(Y)
Q = trapz(X,Y)
Q = trapz(___,dim)
clear all;
t=-2:0.1:2;
for i=1:length(t)
x(i)=1;
end;
k=0;
for f=-5:0.1:5
k=k+1;
X(k)=trapz(t,exp(-sqrt(-1)*2*3.141*f*t));
end
f1=-5:0.1:5;
plot(f1,X);
title('Continuous Time Fourier Transform Of Rectangular pulse without using trapezoid');

Output:

Conclusion: In this program we learnt how to execute a program by plotting


continuous time Fourier transform of rectangular pulse by using trapezoid
function.
Question Write a program in MATLAB to determine and plot the Fourier
transform of following signals :
1. x(t)=e-a|t|

for a=1
clear all
clc
t1=-2:0.01:00;
t=-20:0.01:20;
for i=1:length(t)
if t(i)>=0
x(i)=exp(-t(i));
end
if t(i) <0
x(i)=exp(t(i));
end
end
subplot (2,1,1)
plot(t,x)
t2=0:0.01:2;
k=0;
for f=-20:0.1:20
k=k+1;
y1(k)=trapz(t,x.*exp(t*(1i*2*f*pi)));
%y2(k)=trapz(t2,x.*exp(t2*(1i*2*f*pi)));
end
f=-20:0.1:20;
%y=y1+y2;
%plot(f,y)
%subplot (2,1,1)
z=abs(y1);
subplot(2,1,2)
plot(f,z)

Output:
2. x(t) = 1/(1+t2)

clear all
clc
t=-20:0.01:20;
x=1./(t.^2 + 1);
subplot (2,1,1)
plot(t,x)
grid on
k=0;
for f=-20:0.1:20
k=k+1;
y1(k)=trapz(t,x.*exp(t*(1i*2*f*pi)));
end
f=-20:0.1:20;
z=abs(y1);
subplot(2,1,2)
plot(f,z)
grid on

Output:

Вам также может понравиться