To compute magnitude and phase spectrum

조회 수: 296 (최근 30일)
Sri Srujan Gollapudi
Sri Srujan Gollapudi 2019년 10월 3일
댓글: Juan Palomo 2022년 5월 13일
Hello,
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.
44.JPG
This is the function.
  댓글 수: 2
Shubham Gupta
Shubham Gupta 2019년 10월 4일
Where is 'F' being used in the function? Also, what do you mean by 'magnitude of the function'?
Sri Srujan Gollapudi
Sri Srujan Gollapudi 2019년 10월 5일
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?

댓글을 달려면 로그인하십시오.

채택된 답변

Deepak Kumar
Deepak Kumar 2019년 10월 7일
편집: Deepak Kumar 2019년 10월 11일
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.
clc
clear
close all
A=2;
a=4;
fs=1000; % Sampling frequency
t=0:1/fs:1; %Time
x=A*exp(-a.*t); %Signal
plot(t,x) %Plotting the time domain signal
xlabel('t');
ylabel('x(t)');
title('Time domain Signal')
N=length(x);
N1=2^nextpow2(N);
X=fft(x,N1);
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
figure
plot(f,(X_mag/N1)); %Plotting the Magnitude Spectrum after Normalization
xlabel('Frequency (Hz)');
ylabel('Magnitude Spectrum');
title('Magnitude Spectrum vs f')
figure
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:
  댓글 수: 5
Gowtham K
Gowtham K 2020년 11월 15일
thanks
Juan Palomo
Juan Palomo 2022년 5월 13일
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 https://es.mathworks.com/help/matlab/ref/fft.html?lang=en "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);
"

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by