0% found this document useful (0 votes)
11 views

Lab 5

The document is a lab assignment on Fourier transforms and inverse Fourier transforms. It contains two problems - the first asks to find the Fourier transform and inverse Fourier transform of the difference of two unit step functions, and plot the graphs. The second asks to plot the graph of the addition of three cosine functions, and take its Fourier transform. For the first problem, it calculates the Fourier transform as sin(2πw)/(πw) and the inverse Fourier transform as a piecewise function. For the second problem, it plots the sum of the three cosine functions, then takes its Fourier transform and plots the magnitude against frequency.

Uploaded by

Manish Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Lab 5

The document is a lab assignment on Fourier transforms and inverse Fourier transforms. It contains two problems - the first asks to find the Fourier transform and inverse Fourier transform of the difference of two unit step functions, and plot the graphs. The second asks to plot the graph of the addition of three cosine functions, and take its Fourier transform. For the first problem, it calculates the Fourier transform as sin(2πw)/(πw) and the inverse Fourier transform as a piecewise function. For the second problem, it plots the sum of the three cosine functions, then takes its Fourier transform and plots the magnitude against frequency.

Uploaded by

Manish Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Lab Assignment – 5

Subject – Signals and System

Fourier Transforms and Inverse Fourier Transforms

Name: Azad Mosarof


Roll: 21CS8021

Fourier Transform of a function f (t) = ∫ e


− j 2 πwt
f ( t ) dt .
−∞

Inverse Fourier Transform of a function F (w) = ∫ e F ( w ) dw .


jwt

−∞

1. Write the Fourier Transform of a function which is the difference of two unit functions.
Find its Inverse Fourier Transform as well as plot the graphs.

We are assuming the function to be Heaviside (t+1)-Heaviside (t-1).

Code:
import numpy as np
import matplotlib.pyplot as plt
from sympy import *

a = Symbol('a', real = True, positive = True)


x = Symbol('x', real = True)
w = Symbol('w', real = True, positive = True)
t = Symbol('t', real = True)

f = Heaviside(t+1) - Heaviside(t-1)
plot(f, (t,-3,3))

F = fourier_transform(f, t, w, noconds = True)


print(F)

fi = inverse_fourier_transform(F, w, t, noconds=True)
print(fi)
plot(F, (w,-10,10))

Outputs : (in order)

sin(2*pi*w)/(pi*w)
Piecewise((-t/Abs(t) + 1, (t > 1) | (t < -1)), (1, True))

2. Plot the graph for a function, which is the addition of three


cosine functions.

f1 = cos(2*pi*t)
f2 = cos(4*pi*t)
f3 = cos(6*pi*t)
plot(f1+f2+f3, (t,-2,2))
t = np.linspace(-1, 1, num=5000)
f1 = np.cos(2 * np.pi * t)
f2 = np.cos(4 * np.pi * t)
f3 = np.cos(6 * np.pi * t)
f = f1 + f2 + f3
F = np.fft.fft(f)
freq = np.fft.fftfreq(len(t), t[1] - t[0])
plt.plot(freq, np.abs(F))
plt.xlim([-10, 10])
plt.xlabel('Frequency (Hz)')
plt.ylabel('Magnitude')
plt.show()

Outputs: (in order)

You might also like