FT and Amplitude Phase plot in matlab

The function I need to find the fourier transform of is: x = (t-5)^2/e^8t , t>5
and I want to plot the amplitude spectrum.
This is the code I've written so far but it doesn't seem to work properly.
%%%%
x2 = ((t-5)^2)/exp(8*t);
x2_FT = fourier(x2);
w_values=-100:100;
X_values=double(subs(x2_FT,w,w_values));
subplot(2,1,1)
fplot(t,x2,'-b'); hold on; title('Signal'); grid on;
subplot(2,1,2)
plot(w_values, abs(X_values),'*'); title('Amplitude Plot'); grid on;
%%%%

Also any help on how to actually solve the fourier transform of the above mentioned function will be greatly appreciated.
Thanks in advance!

3 commentaires

dpb
dpb le 11 Juin 2022
See example fft
swlinas
swlinas le 12 Juin 2022
Thanks, i'll check it out!
Paul
Paul le 12 Juin 2022
Even assuming that the OP wants the DFT and not the CTFT, how would the DFT be applicable here, insofar as x(t) is of inifinite duration? Just pick some value of t above which x(t) is assumed to be zero?

Connectez-vous pour commenter.

 Réponse acceptée

Try this —
syms t w
x2 = ((t-5)^2)/exp(8*t)
x2 = 
x2_FT = int(x2*exp(-1j*w*t), t, -1, 1)
x2_FT = 
figure
fplot(real(x2_FT), [-100 100])
hold on
fplot(imag(x2_FT), [-100 100])
fplot(abs(x2_FT), [-100 100], '-g', 'LineWidth',2)
hold off
grid
legend('Re(x2\_FT)','Im(x2\_FT)','|x2\_FT|', 'Location','best')
% x2_FT = fourier(x2)
w_values=-100:100;
X_values=double(subs(x2_FT,w,w_values));
figure
subplot(2,1,1)
fplot(t,x2,'-b'); hold on; title('Signal'); grid on;
subplot(2,1,2)
plot(w_values, abs(X_values),'*'); title('Amplitude Plot'); grid on;
I find that is occasionally necessary to do the specific integration to get the desired Fourier transform rather than using the fourier function.
.

6 commentaires

swlinas
swlinas le 12 Juin 2022
This is amazing, thank you very much!
Star Strider
Star Strider le 12 Juin 2022
As always, my pleasure!
Paul
Paul le 12 Juin 2022
Couple of questions:
How can x2(t), as writen, have a Fourier transform? As the plot shows, x2(t) goes off to infinity for t<0, which would suggest the deifning integral doesn't converge.
Which then leads to the second question ...
Why are the limits of integration for x2_FT from -1 to 1? By definition, shouldn't the limits be -inf to inf insofar as x2(t) is always positive?
Defining the integration time limits as (0,5), with respect to the plot provided in the original code, we get:
syms t w
x2 = ((t-5)^2)/exp(8*t)
x2 = 
x2_FT = int(x2*exp(-1j*w*t), t, 0, 5)
x2_FT = 
figure
fplot(real(x2_FT), [-100 100])
hold on
fplot(imag(x2_FT), [-100 100])
fplot(abs(x2_FT), [-100 100], '-g', 'LineWidth',2)
hold off
grid
legend('Re(x2\_FT)','Im(x2\_FT)','|x2\_FT|', 'Location','best')
% x2_FT = fourier(x2)
w_values=-100:100;
X_values=double(subs(x2_FT,w,w_values));
figure
subplot(2,1,1)
fplot(t,x2,'-b'); hold on; title('Signal'); grid on;
subplot(2,1,2)
plot(w_values, abs(X_values),'*'); title('Amplitude Plot'); grid on;
Producing essentially the same result. (With some functions, symmetric ± integration limits produce closed solutions with trigonometric functions. Here, they do not.) The integration limits are otherwsie not explicitly stated.
.
Paul
Paul le 12 Juin 2022
How are the results essentially the same? In the first case, with the integration taken over [-1,1], the amplitude plot peaks at ~12000, but with the integration over [0,5] it peaks at 3. And the plots of the Re and Im parts don't seem to be essentially the same either, with lots of osciallations in the former and none in the latter.
But the bigger question is, what is the justification for these seemingly arbitrary limits of integration, neither of which seem to comport with the definition of the Fourier transform integral as it would apply to this function?
Using the limits of [-1,1] implies that x2(t) is zero outside that interval, and using [0,5] implies x2(t) is zero outside of that interval. But neither of those implications is true for x2(t).
Star Strider
Star Strider le 12 Juin 2022
I have written everything I intend to about this.

Connectez-vous pour commenter.

Plus de réponses (1)

The code as shown has at least two issues. When using symbolic math, need to declare variables appropriately
syms t w real
Because x2 is zero for t < 5 (not stated explicilty, but implied by the question), need to multiply by heaviside
x2(t) = ((t-5)^2)/exp(8*t)*heaviside(t-5);
figure
fplot(x2,[0 10])
xlabel('t');ylabel('x2')
Perhaps the solution can be obtained starting from here ....

Catégories

En savoir plus sur Language Fundamentals dans Centre d'aide et File Exchange

Produits

Version

R2022a

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by