필터 지우기
필터 지우기

How to calculate Amplitude and phase out of FFT transform of the signal ?

조회 수: 10 (최근 30일)
Hi All ! How are you people ? I have a question in matlab: I tried to write a code that finds an Amplitude and Phase_shift of the Periodic signal(cosine wave) BUT it doesn't give the correct answer(instead of Amplitude=10,i am getting answer Amplitude=5)!!! Could someone to see the code and to tell me what i'am doing the wrong way ?
%THE CODE function ask_portal_fft per=24;%number of periods w=2*pi*per;% points=1000; t=linspace(0,1,points); a=10;%the amplitude so the answer of Amplitude suppose to be 10 y=a*cos(w*t-1);%Phase shift suppose to be 1 %plot(y)%for debug %-------------
Y=fft(y); N=length(Y); Psd=Y.*conj(Y); mx=find(Psd==max(Psd),1); Amplitude=sqrt(Psd(mx)); Amplitude=Amplitude/N;%=4.99,why not 10 ?
Phase=angle(Y(mx));%suppose to be 1 end

채택된 답변

Dr. Seis
Dr. Seis 2012년 3월 11일
This reminds me of the same issure here:
Basically your maximum amplitude should be at 24Hz, right? Here is the Fourier transform of your signal at 24Hz.
>> ff = 24;
>> G_ff = quad(@(t)10*cos(2*pi*ff*t-1).*exp(-1i*2*pi*ff*t),0,1)
G_ff =
2.7015 - 4.2074i
>> sqrt(G_ff*conj(G_ff))
ans =
5
It's 5 !!!
  댓글 수: 2
Dr. Seis
Dr. Seis 2012년 3월 11일
However, to scale the FFT you should be using the time increment (dt = 1/Fs) instead of the number of points (N). See my reasons here:
http://www.mathworks.com/matlabcentral/answers/15770-scaling-the-fft-and-the-ifft
The result Y = fft(y)/N comes out very similar to Y = fft(y)*dt, where dt is equal to 0.001001 in your example, by the fact that 1/N is almost equal to dt.
alex
alex 2012년 8월 31일
Thank you for answer I had to process the data that taken from the movement sensors in the mice cage.The expected Period of their activity was 24 hours. That's the reason I asked you whether the my algorithm was correct.

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

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by