Trouble with understanding frequency bins in MATLAB's documentation (FFT Phase plots)
Show older comments
Hello everyone,
I'm working on plotting phase diagrams after performing an FFT, and although the plots appear to be correct, I'm getting what I see (rightly or wrongly) as 'extra' information.
I found some documentation that might illustrate what I mean: http://www.mathworks.co.uk/help/techdoc/math/brentm1-1.html
Scrolling down to the bit on plotting that signal's phase (unwrapped), the phase plot shows frequencies from -50 to 50 Hz, although the signal's highest frequency component should be 40 Hz. Thinking it might be the random noise that the code uses, I took that out, leaving only the 15 and 40 Hz components; however, the phase plot still shows phase over -50 to 50 Hz. I have a hunch this corresponds to the nyquist frequency, since the sampling frequency is 100 Hz; however, I don't quite understand why this happens or what it implies. Isn't the x-axis in this case showing frequency bins, and wouldn't this mean that according to the plot the phase is still changing at frequencies where the signal's amplitude is zero?
If anyone could shed some light on this, I would be very grateful!
Thanks,
David
Answers (2)
Wayne King
on 1 Feb 2012
Hi David, the sampling frequency is 100 Hz, so the frequency axis should run from -50 to 50 Hz.
The signal contains random noise:
fs = 100; % Sample frequency (Hz)
t = 0:1/fs:10-1/fs; % 10 sec sample
x = (1.3)*sin(2*pi*15*t) ... % 15 Hz component
+ (1.7)*sin(2*pi*40*(t-2)) ... % 40 Hz component
+ (2.5)*randn(size(t));
The additive white Gaussian noise means that energy will be spread over the entire frequency interval from -50 to 50 Hz.
So it is not correct to say that the signal has no energy at frequencies other than 15 and 40 Hz.
3 Comments
David
on 1 Feb 2012
Dr. Seis
on 1 Feb 2012
The amplitudes at the frequencies other than 15 and 40 Hz are non-zero complex numbers. They have non-zero real and non-zero imaginary parts with amplitudes around the same order of magnitude, which means the angle between them (or phase) will also be non-zero. But if you look at the many, many orders of magnitude difference between amplitudes at 15 or 40 Hz and all other frequencies, you would know that the phase information outside of 15 and 40 Hz is pretty much garbage. This isn't recommended for all cases, but for this case try this out:
y = fftshift(fft(x));
subplot(3,1,1);plot(abs(y)); title('ABS');
subplot(3,1,2);plot(angle(y)); title('Phase ANGLE #1');
subplot(3,1,3);plot(angle(y).*(abs(y)>1e-6)); title('Phase ANGLE #2');
The last plot is basically multiplying the phase angle information by a 1 if the abs amplitude is greater that some tolerance (i.e., 1e-6) or 0 if the abs amplitude is less than that tolerance.
David
on 1 Feb 2012
Wayne King
on 1 Feb 2012
Hi David, Due to the fact that the fft() is a numerical implementation of the DFT (and not the DFT), you may find that even in the case of sinusoidal inputs, other DFT bins may not be identically zero, but will often be extremly small nonzero numbers. For example:
Fs = 100;
t = 0:1/Fs:10-1/Fs;
x = (1.3)*sin(2*pi*15*t)+1.7*sin(2*pi*40*(t-2));
xdft = fft(x);
% now create a copy ydft and remove the DFT coefficients at 15
% and 40 Hz
bins = [151 401 601 851];
ydft = xdft;
ydft(bins) = [];
max(abs(ydft))
You see that the largest magnitude is only on the order of 10^{-11}.
Accordingly, you should not attach any physical intepretation to an argument (phase) based on such a small magnitude.
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!