Symbolically Calculating Fourier Transforms with int()

For the following function:
x_1 = heaviside(t + 0.5) - heaviside(t - 0.5);
I would like to symbolically compute the Fourier Transform using MATLAB's int() function.
Using as my guide, my attempt was as follows:
FX_1 = int(x_1*exp(-1i*omega*t),t,-inf,inf);
The return was unusable. There are obviously other ways to go about getting the Fourier Transform of a function, but in this instance I am specifically looking to do so using the int() function.
Bonus question: how would you plot the magnitude line spectrum of the function? Would the following work?
omega = -100:0:100;
plot(abs(FX_1),omega)

 Accepted Answer

The heaviside step function is simply 1 on the interval you are interested in.
Try this:
syms omega t
FX_1 = int(1*exp(-1i*omega*t),t,-0.5,0.5);
figure
fplot(FX_1, [-50, 50])
grid
Change the fplot limits to be whatever you want them to be.

4 Comments

Thanks! Replacing the limits of integration with the interval of the function worked. I tried extrapolating the result to . See code below:
syms omega t
x_2 = sin(2*pi*t);
FX_1 = int(sin(2*pi*t)*exp(-1i*omega*t),t,0,0.5);
figure
fplot(FX_1, [-50, 50])
grid
In this instance, will we need to change the type of plot or use a discrete version of omega in order to visualize the line spectrum?
My pleasure.
What we need to realise that the Heaviside function is an even function (symmetrical about t=0) witha negligible imaginary part in the Fourier transform, while the sin function is an odd function, so it has a significant imaginary part in the Fourier transform.
Compare —
syms omega t
FX_1 = int(1*exp(-1i*omega*t),t,-0.5,0.5);
figure
fplot(real(FX_1), [-100, 100])
hold on
fplot(imag(FX_1), [-100, 100])
hold off
grid
legend('\Re','\Im')
with
syms omega t
x_2 = sin(2*pi*t);
FX_1 = int(sin(2*pi*t)*exp(-1i*omega*t),t,-0.5,0.5);
figure
fplot(real(FX_1), [-50, 50])
hold on
fplot(imag(FX_1), [-50, 50])
hold off
grid
legend('\Re','\Im')
So we need only to use the hold function, and be certain we plot both the real and imaginary parts of both functions here, in order to see them in their full expressions in the frequency domain.
Awesome, thanks. I didn't realize we could plot the imaginary and real parts in that way. Great advice!

Sign in to comment.

More Answers (0)

Products

Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!