Fourier transform of symbolic function
53 views (last 30 days)
Show older comments
Hi. I would like to see the magnitude and phase spectrum of a symbolic function. I tried using the 'fourier' function on a basic symbolic expression, but it didn't work.
syms t w;
x=sin(2*t);
X=fourier(x);
fplot(abs(X)) // Nothing in this figure
Doing the transform manually works:
T=10;
fX=int(x* exp(1j*w*t), t, -T, T);
fplot(abs(X)/T) // This works
Please can someone let me know how to see the phase and magnitude responses using the 'fourier' function ?
Many thanks
-s
0 Comments
Accepted Answer
Paul
on 10 Sep 2022
Edited: Paul
on 10 Sep 2022
Hi soup,
The Fourier transform of x is
syms t w;
x=sin(2*t);
fourier(x)
fplot() ignores Dirac delta functions. Because there is nothing else to plot, fplot() is empty
The "manual transform"
T = 10; % not sure why T = 10?
simplify(int(x* exp(1j*w*t), t, -T, T),100)
isn't the Fourier transform of x. Rather, it's the Fourier transform of the x multiplied by a rectangular window of length 2T.
sympref('FourierParameters',[1 1]);
simplify(fourier(x*rectangularPulse(-T,T,t)),100)
3 Comments
Paul
on 10 Sep 2022
Edited: Paul
on 10 Sep 2022
As you're seeing, the Fourier transform integral doesn't converge for a periodic signal. However, we can define the Fourier transform of a periodic signal as a Dirac delta impulse train scaled by the signal's Fourier series coefficients, which is exactly what we see as the Fourer transform of a sin function. See this link, for example, for further discussion. Matlab's fourier function knows how to deal with basic periodic functions, like sin and complex exponentials.
Any plot of a signal that contains a Dirac delta will be artifcial. The concept of "magnitude" doesn't really apply to a Dirac delta. Can't really plot it, just have to make up some symbol, like a vertical arrow, to signify where the Dirac delta sits on the real line, as is done in the linked reference.
More Answers (0)
See Also
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!