FT and Amplitude Phase plot in matlab
2 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Star Strider
on 11 Jun 2022
Try this —
syms t w
x2 = ((t-5)^2)/exp(8*t)
x2_FT = int(x2*exp(-1j*w*t), t, -1, 1)
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 Comments
More Answers (1)
Paul
on 11 Jun 2022
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 ....
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!