Uncertainty using FFT function.

Hello all,
I am trying to get the spectral shape of my time domain signal. For this I use FFT. However, the results I get are not as expected and I cannot understand why. My code for FFT is as follows:
NFFT=length(eta);
Fs=2;
transf_length=pow2(nextpow2(NFFT));
transforma = fft(eta,transf_length);
frequ = (0:transf_length-1)*(Fs/transf_length)*2*pi; % to make in radians/s
power = transforma.*conj(transforma)/transf_length;
Everything seems to be fine, but the magnitude of the spectrum when compared to the expected spectrum is not the same (approximately 30 times larger). The first figure shows the FFT vs. the expected spectrum. The second figure shows the FFT power/30 vs. the expected spectrum.
Can someone explain if there is something wrong with my code, or I am just misunderstanding something?
Thanks!

7 件のコメント

Adam
Adam 2014 年 11 月 4 日
What is the length of your eta signal?
Andrejus
Andrejus 2014 年 11 月 4 日
編集済み: Andrejus 2014 年 11 月 4 日
length=21600
Adam
Adam 2014 年 11 月 4 日
I don't have your actual signal, but when I created a signal as:
eta = rand( 21600, 1 ) - 0.5;
and ran your code I ended up with a power spectrum whose total power equalled that of:
sum( eta.^2 );
so I'm not sure why your signal is giving you unexpected results.
Andrejus
Andrejus 2014 年 11 月 4 日
I will share whole code of mine, maybe this will help to understand what is messing my brain. Some things might not work if you have no wafo toolbox installed. If you are very keen to get one you can simply download it from here Wafo. The end results of the code shows three spectral shapes. One is obtained using FFT, one is obtained using wafo toolbox and the last one is a function of wave amplitude spectrum.
Adam
Adam 2014 年 11 月 4 日
When I run your code commenting out the bits related to the Wafo toolbox I end up with a plot just like your second one (without the green plot) with a peak around 1.5
Andrejus
Andrejus 2014 年 11 月 4 日
Yes, but in the code I have applied the division by 30 in order to get values close to expected ones... if you remove division then the first figure in my questions will pop up.
Harry
Harry 2014 年 11 月 4 日
I think you need to strip this problem down to what you are having trouble with. Asking people to install an obscure library to run your code will possibly mean you get less help. If your problem is with the FFT, then you should be able to describe the problem with just a few lines of code.
Maybe plot the FFT of a simple signal, explain why that is correct... then plot the FFT of your signal and describe how it is not as expected.

サインインしてコメントする。

回答 (0 件)

カテゴリ

質問済み:

2014 年 11 月 4 日

コメント済み:

2014 年 11 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by