To compute magnitude and phase spectrum

768 views (last 30 days)
Sri Srujan Gollapudi
Sri Srujan Gollapudi on 3 Oct 2019
Commented: Juan Palomo on 13 May 2022 at 18:42
I have a function, for that I need to find the magnitude and phase spectrum on matlab. Can someone please help me with the code, please?
The parameters are A=2 a=4 -20<=F<=20.
This is the function.
Sri Srujan Gollapudi
Sri Srujan Gollapudi on 5 Oct 2019
Even I'm not sure of that. But if we leave out the limits of F, how can I find the magnitude and phase sepctra with given values of A and a for the above fucntion?

Sign in to comment.

Accepted Answer

Deepak Kumar
Deepak Kumar on 7 Oct 2019
Edited: Deepak Kumar on 11 Oct 2019
I'm not sure what F is referring here.
However, we can find the Magnitude and Phase spectrum of a function using FFT function in matlab. I have wrirren the below code to evalute the magnitude and phase spectrum of the given function and also plotted them.
close all
fs=1000; % Sampling frequency
t=0:1/fs:1; %Time
x=A*exp(-a.*t); %Signal
plot(t,x) %Plotting the time domain signal
title('Time domain Signal')
X=X(1:N1/2);%Discard Half of Points
X_mag=abs(X); %Magnitude Spectrum
X_phase=phase(X); %Phase Spectrum
f=fs*(0:N1/2-1)/N1; %Frequency axis
plot(f,(X_mag/N1)); %Plotting the Magnitude Spectrum after Normalization
xlabel('Frequency (Hz)');
ylabel('Magnitude Spectrum');
title('Magnitude Spectrum vs f')
plot(f,X_phase); %Plotting the frequency domain
xlabel('Frequency (Hz)');
ylabel('Phase Spectrum');
title('Phase Spectrum vs f')
Please refer the below documentation for more details about the FFT function:
Juan Palomo
Juan Palomo on 13 May 2022 at 18:42
hi, if this spectrum is the single side spectrum (comment on code:
X=X(1:N1/2);%Discard Half of Points
) should'nt the amplitude be multiplied by 2 like in "Compute the two-sided spectrum P2. Then compute the single-sided spectrum P1 based on P2 and the even-valued signal length L.
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!