Wednesday, September 11, 2019

matlab - baffled by fft phase spectrum!


A very simple MATLAB experiment:


f = 200;  
fs = 1000;
t = 0: 1/fs : 1;
x = cos(2*pi*f*t);
plot(angle(fftshift(fft(x))));


And here's the output: enter image description here


Now, made a minor change to the above code snippet; reducing the time duration by just 1 sample, as follows:


f = 200;  
fs = 1000;
t = 0: 1/fs : 1 - 1/fs;
x = cos(2*pi*f*t);
plot(angle(fftshift(fft(x))));

And the phase spectrum goes totally crazy:



enter image description here


Questions:




  1. In the first plot, I was hoping to see a zero phase at bin 700 which corresponds to the positive frequency of 200 in this example. That doesn't seem to be the case. Secondly, I don't understand the linear parts of the graph in plot 1. I do appreciate phase components that could potentially exist due to the so-called numerical noise, but then how could that noise be so 'linear' in phase?




  2. In the second plot, why removing just one sample would have such a drastic impact on the phase plot?





  3. Am I doing something fundamentally wrong here?






No comments:

Post a Comment

digital communications - Understanding the Matched Filter

I have a question about matched filtering. Does the matched filter maximise the SNR at the moment of decision only? As far as I understand, ...