how can I compute and plot the amplitude and phase of this signal for example after doing Fourier transform !

5 views (last 30 days)
I'm new in matlab and I have this function => exp(-t^2) I did the fourier transform
x=sym('exp(-t^2)')
X=fourier(x)
Xf=subs(X,'2*pi*f','w')
I have done the Fourier transform
now i want to compute and plot the amplitude and the phase of this signal !
also how to do it if i have to add two functions for example x=(e^-3t + e^-2t)u(t) ?

Answers (1)

Prateekshya
Prateekshya on 21 Oct 2024
Hello Mona,
To compute and plot the amplitude and phase of a signal after performing its Fourier transform in MATLAB, you can follow these steps. I'll guide you through the process for both the Gaussian function and the sum of two exponential functions .
Fourier Transform of
First, let's compute and plot the amplitude and phase of the Fourier transform of .
syms t w
% Define the function
x = exp(-t^2);
% Compute the Fourier Transform
X = fourier(x, t, w);
% Substitute '2*pi*f' with 'w' if needed (in this case, it's already in terms of 'w')
% Xf = subs(X, '2*pi*f', 'w'); % Not necessary here
% Define frequency range for plotting
w_vals = linspace(-10, 10, 1000);
% Evaluate the Fourier Transform
X_vals = double(subs(X, w, w_vals));
% Compute amplitude and phase
amplitude = abs(X_vals);
phase = angle(X_vals);
% Plot amplitude
figure;
subplot(2, 1, 1);
plot(w_vals, amplitude);
title('Amplitude Spectrum');
xlabel('Frequency (rad/s)');
ylabel('Amplitude');
% Plot phase
subplot(2, 1, 2);
plot(w_vals, phase);
title('Phase Spectrum');
xlabel('Frequency (rad/s)');
ylabel('Phase (radians)');
Fourier Transform of
For this part, we need to include the unit step function , which can be represented in MATLAB using the heaviside function.
syms t w
% Define the function with unit step
x = (exp(-3*t) + exp(-2*t)) * heaviside(t);
% Compute the Fourier Transform
X = fourier(x, t, w);
% Define frequency range for plotting
w_vals = linspace(-10, 10, 1000);
% Evaluate the Fourier Transform
X_vals = double(subs(X, w, w_vals));
% Compute amplitude and phase
amplitude = abs(X_vals);
phase = angle(X_vals);
% Plot amplitude
figure;
subplot(2, 1, 1);
plot(w_vals, amplitude);
title('Amplitude Spectrum of (e^{-3t} + e^{-2t})u(t)');
xlabel('Frequency (rad/s)');
ylabel('Amplitude');
% Plot phase
subplot(2, 1, 2);
plot(w_vals, phase);
title('Phase Spectrum of (e^{-3t} + e^{-2t})u(t)');
xlabel('Frequency (rad/s)');
ylabel('Phase (radians)');
I hope this helps!

Community Treasure Hunt

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

Start Hunting!