Hello,
since several days i'm trying to understand the fft function of Matlab and the corresponding output. But i still have some problems and hope you can help me.
I have to analyse a broad band timediscret 3D acceleration spectrum and i like to know the frequencies and the corresponding amplitudes. To test my approach i wrote a test programm with a generated sin+whitenoise to check the different procedures. But i couldn't find one, which satisfies my concern. Either i get the wrong amplitudes or to much noise in the signal.
Also i have hugh problems to understand the scaling of the yachsis.
It would be nice, if someone could help me and explain my mistakes.
function ffttest
N=128;%Number of Points
fs=256;%sample rate
f1=60;%signal 1 frequency
f2=80;%signal 2 frequency
a1=1.2;%signal 1 amplitude
a2=2.3;%signal 2 amplitude
whitenoise=randn(1,N);
%Timevalue
t=(0:N1)/fs;
y=a1*sin(2*pi*f1*t)+a2*sin(2*pi*f2*t)+whitenoise;
subplot(2,3,1);
plot(y);
%Reference FFT
h=fft(y);
freq=fs*(0:N/2)/N;
subplot(2,3,2);
fg=2/N*abs(h(1:N/2+1));
plot(freq,fg);
xlabel('ReferenceFFT');
%1. Test
y_HannWnd = y'.*hanning(N);
Ydft_HannWnd = fft(y_HannWnd,N)/N;
mYdft = abs(Ydft_HannWnd);
mYdft = mYdft (1:N/2+1);
mYdft (2:end1) = 2* mYdft(2:end1);
f = fs/2*linspace(0,1,N/2+1);
subplot(2,3,3)
plot(f,2*mYdft);
xlabel('Inet 2');
%2. Simple FFT Plot
windowHanning = window(@hann, N);
windowedSignal = windowHanning.*y;
windowedSignal = windowedSignal * 2/sqrt(1.5);
windowedSignal = windowedSignal  mean(windowedSignal);
FwindowedSignal = fft(windowedSignal);
power = FwindowedSignal.*conj(FwindowedSignal)/N;
power_h = 2*power(1:ceil(N/2)+1);
subplot(2,3,4);
plot(freq,power_h);
xlabel('INET FFT');
%3. My FFT used for the original Datafiles
for i=1:N;
w(i)=0.5*(1cos(2*pi*i/N));
end
x=y.*w;
daydata_fft=fft(x',N);
spectral_densityx=2*daydata_fft.* conj(daydata_fft) /(w*w') * (1/fs); %Power Spectral Density of the excitation [1/Hz]
freq1=1/(1/fs)*(0:N/2)/N; %Frequenz Skala in [Hz]
subplot(2,3,5);
plot(freq,spectral_densityx(1:(N/2)+1));
xlabel('MY FFT');
