fft phase accuracy
Show older comments
Hello,
I have a problem with my fft analysis, it seems to work for the amplitudes, the spectrum ist the same as in the test function, but the phase ist different. If i change the frequency of the test function it works better, but there's still a difference. Later I want to use the file to analyze a signal from simulink.
Here my test fft:
yout.time=linspace(0,1.6384,16384);
yout.signals.values = sin(2*pi*36*yout.time) + 3*sin(2*pi*18*yout.time+(pi/2))+5;
Fs = 10000; % Sampling frequency
T = 1/Fs; % Sample time
L = length(yout.time);% Length of signal
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
fsignal=yout.signals.values-mean(yout.signals.values);
ha=hann(L);
fsignal=2*fsignal(:).*ha;
Y = fft(fsignal,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
phase = angle(Y);
If I use the unwrap command it destroys the values completely, I get values about 20 which should be about +-pi.
Thanks in advance,
Regards
1 Comment
Wayne King
on 15 Feb 2012
Pleae format your code for readability.
Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!