Why do I get a different Phase graph, when using FFT versus hand calculations?

Hi Matlab,
I have calculated the Fourier transform for an equation (by hand) and than entered this into matlab using (FFT) to verify my answer. When I plot the magnitude (against frequency), I get very similar graphs. However when I plot the phase (against frequency), I get two different looking graphs, however the magnitude of the phase looks the same. Can you please explain, I have attached images and code used.
The function I am solving is:
s1 = (t1-3).*exp(-t1).*heaviside(t1-3);
The Fourier Transform of this (Hand Calculation): S1f = (exp(-3.*(1+1i*2*pi*f1)))./((1+1i*2*pi*f1).^2);
I than used FFT to solve s1, to verify my answer above. I than used matlab to plot magitude and phase graphs of the hand calcs and FFT calcs. The magnitude graphs looks ok, however something is wrong with the phase graphs.
Kind Regards Peter

 Accepted Answer

Hello Peter,
This is pretty close and it definitely helps that it was complete working code. There are just a couple of things. Since you know that a highly oscillatory time-shift style component is going to be in the final result, it makes sense to divide that factor out in both methods and compare the slowly varying part so you can actually see what is going on. In the hand calculation if you replace
S1f = (exp(-3.*(1+1i*2*pi*f1)))./((1+1i*2*pi*f1).^2);
with
S1f = (exp(-3.*(1)))./((1+1i*2*pi*f1).^2);
and in the fft part replace
plot(k1,angle(S1k))
with
plot(k1,angle(S1k.*exp(3*1i*2*pi*k1)))
then you will get a good comparison of the important part of the phase shift. Except for one more thing. Your time record is not long enough, so the exponential has not rung down before it reaches the end. There is no chance to get the right phase, and you don't get quite the right peak magnitude either, because the fft doesn't capture the entire area of the time waveform. Zooming in on the two magnitude plots shows that the peaks differ by a few percent.
In the fft part when you create the t1 vector, replacing 8 with 16 gives a time record that is long enough and the two methods agree. You get a two-pole-filter style phase shift of (almost) -2pi across the frequency span. In the fft phase plot there are some wacky phases at each end, but the magnitude of the signal is small out there so it does not really matter.

More Answers (0)

This question is closed.

Tags

No tags entered yet.

Asked:

on 10 May 2017

Closed:

on 18 Jul 2017

Community Treasure Hunt

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

Start Hunting!