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 件のコメント
mouh nyquist
2015 年 1 月 1 日
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
Shoaibur Rahman
2015 年 1 月 1 日
I would use:
amplitude=max(ifft(fft(x)))
This will give the amplitude of x.
mouh nyquist
2015 年 1 月 1 日
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
Shoaibur Rahman
2015 年 1 月 1 日
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.
mouh nyquist
2015 年 1 月 1 日
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
Shoaibur Rahman
2015 年 1 月 2 日
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.
mouh nyquist
2015 年 1 月 2 日
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 '});
Shoaibur Rahman
2015 年 1 月 2 日
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.
mouh nyquist
2015 年 1 月 2 日
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
Shoaibur Rahman
2015 年 1 月 2 日
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));
mouh nyquist
2015 年 1 月 2 日
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
