Fourier transform of symbolic function

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

 Respuesta aceptada

Paul
Paul el 10 de Sept. de 2022
Editada: Paul el 10 de Sept. de 2022
Hi soup,
The Fourier transform of x is
syms t w;
x=sin(2*t);
fourier(x)
ans = 
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)
ans = 
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)
ans = 

3 comentarios

soup
soup el 10 de Sept. de 2022
Hi Paul,
Thanks for the resonse! T=10 was arbitrary really. T=inf (integrating over -inf to inf ) didnt work, (I dont know why), and having some value there made things work..
T=10;
fX=int(x* exp(1j*w*t), t, -T, T)
do you know why if I use T=inf above, it doesnt work?
" fplot() ignores Dirac delta functions"
Does that mean it is impossible to plot the fourier transform magnitude and phase of a sinusoid using 'fourier'?
Thanks for your help.
-s
Paul
Paul el 10 de Sept. de 2022
Editada: Paul el 10 de Sept. de 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.
soup
soup el 10 de Sept. de 2022
Thank you very much. I'll read the article : )
-s

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

el 10 de Sept. de 2022

Editada:

el 10 de Sept. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by