problem in Hanning window with FFT
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
where is the error in my program, why I don't get the amplitude is not 4 .
fs=300;
N=3000;
t = (1:N)/fs; % Time vector
x = 4*cos(2*pi*100*t);
% FFT
fn=hanning(N); %fenetre de hanning
ft=abs(fft(x'.*fn));%fft
plot(ft);
채택된 답변
Shoaibur Rahman
2015년 1월 1일
Here are few things: Your plot shows the amplitude of Fourier transform, not the original signal. So, the amplitude may not be 4 (amplitude of the signal). Indeed, the amplitude of fft is determined so that the power of the signal remains same before and after the transform. Lets say, Y = x'.*fn
Y = x'.*fn;
Power_Y = sum(Y.^2) % power in time domain
fftY = fft(Y);
Power_fftY = sum(fftY.*conj(fftY))/length(fftY) % power in frequency domain
The amplitude after transformation is set so that Power_Y = Power_fftY
To get the amplitude back, use ifft that is shown in subplot(313) below. Compare these three plots:
subplot(311), plot(Y); % original signal
subplot(312), plot(abs(fftY)); % fft
subplot(313), plot(ifft(fftY)); % ifft
댓글 수: 13
thank you a lot for the answer; so we can't see the amplitude of the signal in the FFT?; in normal FFT without hannig ;I used this amplitude=abs(fft(x)/length(fft(x))*2;But in this case it not work
I would use:
amplitude=max(ifft(fft(x)))
This will give the amplitude of x.
thank you a lot again ; yes I get amplitude =4; please tell me how to use this in the FFT ; I want to do a correct code for FFT with hanning window
Could you please see the doc for fft? You can use this function in various ways, and purposes. So, please read the doc first, and lets discuss the specific question on it, if you may have.
It will also be very helpful if you do have a decent knowledge about Fourier series and transform, if not, at least the basics.
yes I have read the FFT doc and a have a knowledge about Fourier series and transform
this is the program for simple FFT
fs=300;
N=3000;
t = (1:N)/fs; % Time vector
x = 4*cos(2*pi*100*t);
%========================== FFT ================================
fs=300;
X=fft(x); %FFT
df=fs/length(X) %frequency resolution
f=(0:1:length(X)/2)*df; %frequency axis
M=abs(X)/length(x)*2; %amplitude spectrum
plot(f,M(1:length(f)));
xlabel({'Frequancy (Hz)'}); ylabel({'Amplitude '});
the problem is when I use the hannig window
Where do you want to use hanning window in this code? I guess it's after x = 4*cos(2*pi*100*t); right? I yes, use a couple lines before you perform the fft.
x = 4*cos(2*pi*100*t);
h = hann(N);
x = x'.*h;
Then use the code you have written for computing fft.
thank you a lot again; yes ; like I do in my first question; the problem is in the amplitude ; if I do this code the amplitude is 2;
fs=300;
N=3000;
t = (1:N)/fs; % Time vector
x = 4*cos(2*pi*100*t);
h = hann(N);
x = x'.*h;
%========================== FFT ================================
fs=300;
X=fft(x); %FFT
df=fs/length(X) %frequency resolution
f=(0:1:length(X)/2)*df; %frequency axis
M=abs(X)/length(x)*2; %amplitude spectrum
plot(f,M(1:length(f)));
xlabel({'Frequancy (Hz)'}); ylabel({'Amplitude '});
Right, the amplitude off fft(x) is 2. It does not mean that x has an amplitude of 2 anyway. To get the amplitude of x, use:
X=fft(x);
max(ifft(X))
This gives 4, which makes sense.
thank you a lot again for all your helps; but I want to see the right amplitude in the FFT because may be I will have a 1000 sinus for exemple ; I want the right code for FFT with hanning widow
Rewrite M=(abs(X)/max(abs(X)))*max(ifft(X));
Please note, it is not the actual fft amplitude, but we are manipulating to make it equal to our original signal.
mouh nyquist
2015년 1월 2일
편집: mouh nyquist
2015년 1월 2일
thank you a lot;
when I use your code with x = 4*cos(2*pi*100*t)+8*cos(2*pi*10*t); I get amplitude = 12 I think we must multiplied by 2 for hanning window like this (M=(abs(X)/length(x)*2)*2) that always give a correct amplitude
Shoaibur Rahman
2015년 1월 2일
편집: Shoaibur Rahman
2015년 1월 2일
x = 4*cos(2*pi*100*t)+8*cos(2*pi*10*t);
Its amplitude is 12, range is 12*2 = 24
Now lets include the hanning window, say:
h = hann(N); % as you defined N in your code
Now, x.*h' will have a minimum value of -9.8 and a maximum of 12. You can also plot to see this. So, do you want to show amplitude equal to 21.8? If yes, then instead of multiplying by 2, use:
M=(abs(X)/max(abs(X)))*range(ifft(X));
thank you for all your helps ; now I understand very well the FFT with hanning window ;thank you again
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Spectral Analysis에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
