필터 지우기
필터 지우기

In the fft example on MATLAB help, why do we multiply by 2?

조회 수: 34 (최근 30일)
David Cho
David Cho 2017년 10월 31일
댓글: Star Strider 2019년 9월 20일
Hi, I found the following 'fft' example on MATLAB help (https://nl.mathworks.com/help/matlab/ref/fft.html)
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
X = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
Y = fft(X);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1); % don't know why we have to mutiply by 2 and why the range is from 2 to (end-1)
f = Fs*(0:(L/2))/L;
plot(f,P1)
My question lies in the line #9: P1(2:end-1) = 2*P1(2:end-1); I do not understand why we have to mutiply by 2 and why the range is from 2 to (end-1).
I shall be obliged if anyone could help on this question.
Thank you.
  댓글 수: 2
kamrul islam sharek
kamrul islam sharek 2019년 9월 20일
a=imread('grey.jpg');
g=fspecial('gaussian',256,10);
max(g(:))
gi=mat2gray(g);
max(g1(:));
af=fftshift(fft2(a));
agi= a.*gi;
fftshow(ag1)
ag1i=ifft2(ag1);
fftshow(ag1i)
my problem is line no 7.plewase help to getting out this problem
Star Strider
Star Strider 2019년 9월 20일
Post this as a new Question, not here. Include the image.

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

채택된 답변

Star Strider
Star Strider 2017년 10월 31일
The Fourier transform (link) by definition is two-sided, symmetrical about 0, with frequencies going from -Inf to +Inf. (In practice, the frequency content is limited by the signal length.) The energy at each frequency is represented equally on both the positive and negative halves of the spectrum at one-half the original signal energy (so the total energy remains the same).
Taking the one-sided Fourier transform, as done here, then requires that the amplitude of half the spectrum be multiplied by 2 in order to represent the signal amplitude accurately.
  댓글 수: 4
David Cho
David Cho 2017년 10월 31일
Thank you very much for your kind answer! It helped me a lot to understand the MATLAB 'fft' command more.
Star Strider
Star Strider 2017년 10월 31일
As always, my pleasure!

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

추가 답변 (1개)

george veropoulos
george veropoulos 2018년 7월 9일
Hi.. i have an other question the the quantity P2 = abs(Y/L) must multiply by Ts... i make a code to compare the FFt RESULTS with fourier transform
N=128; t=linspace(0,3,N); f=2*exp(-3*t); Ts=t(2)-t(1); Ws=2*pi/Ts; F=fft(f); Fp=F(1:N/2+1)*Ts;
W=Ws*(0:N/2)/N; Fa=2./(3+j*W);
plot(W/(2*pi),abs(Fa),'--',W/(2*pi),abs(Fp),'-'); xlabel('Frequency, Hz'), ylabel('|F(f)|');
legend('analytical','numerical')
when myltiply by Ts the resluts are same...
thank you George

카테고리

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