# FT and Amplitude Phase plot in matlab

3 views (last 30 days)
swlinas on 11 Jun 2022
Edited: swlinas on 17 Jun 2022

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 CommentsShowHide 2 older comments
Paul on 12 Jun 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?

Sign in to comment.

### Accepted Answer

Star Strider on 11 Jun 2022
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 CommentsShowHide 5 older comments
Star Strider on 12 Jun 2022
I have written everything I intend to about this.

Sign in to comment.

### 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 ....
##### 1 CommentShowHide None
swlinas on 12 Jun 2022
I see. Thanks a lot!

Sign in to comment.

R2022a

### Community Treasure Hunt

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

Start Hunting!