Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Phase Angle Plot of fft
Replies: 6   Last Post: Oct 1, 2013 5:13 PM

 Messages: [ Previous | Next ]
 Derek Goring Posts: 3,922 Registered: 12/7/04
Re: Phase Angle Plot of fft
Posted: Oct 1, 2013 3:54 PM

On Wednesday, October 2, 2013 8:40:10 AM UTC+13, J wrote:
> "someone" wrote in message <l2f69d\$8mk\$1@newscl01ah.mathworks.com>...
>

> > "J " <jr360983@dal.ca> wrote in message <l2f4mm\$3ki\$1@newscl01ah.mathworks.com>...
>
> > > Hi,
>
> > >
>
> > > I am trying to plot the phase angle of an fft, the values I'm getting in radians don't seem to be right?
>
> > >
>
> > > Here is my code:
>
> > >
>
> > > Fs = 1000; % Sampling frequency
>
> > > T = 1/Fs; % Sample time
>
> > > L = 1000; % Length of signal
>
> > > t = (0:L-1)*T; % Time vector
>
> > > % Sum of a 50 Hz sinusoid and a 120 Hz sinusoid
>
> > > x = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
>
> > > y = x + 2*randn(size(t)); % Sinusoids plus noise
>
> > > plot(Fs*t(1:50),y(1:50))
>
> > > title('Signal Corrupted with Zero-Mean Random Noise')
>
> > > xlabel('time (milliseconds)')
>
> > >
>
> > >
>
> > > NFFT = 2^nextpow2(L); % Next power of 2 from length of y
>
> > > Y = fft(y,NFFT)/L;
>
> > > f = Fs/2*linspace(0,1,NFFT/2+1);
>
> > >
>
> > > %Phase Angle
>
> > > phi = unwrap(angle(Y(1:NFFT/2+1)));
>
> > >
>
> > > % Plot single-sided amplitude spectrum.
>
> > > figure;
>
> > > plot(f,2*abs(Y(1:NFFT/2+1)))
>
> > > title('Single-Sided Amplitude Spectrum of y(t)')
>
> > > xlabel('Frequency (Hz)')
>
> > > ylabel('|Y(f)|')
>
> > >
>
> > > figure;
>
> > > plot(f, phi);
>
> > >
>
> > > Any insight would help.
>
> > >
>
> > > Thanks,
>
> > > J
>
> > >
>
> > >
>
> > >
>
> >
>
> > Why do you think they are not right?
>
>
>
>
>
>
>
> Because I figured all the values would fall between Pi and negative Pi

Then why bother to unwrap?

Date Subject Author
10/1/13 J
10/1/13 Curious
10/1/13 J
10/1/13 Derek Goring
10/1/13 J
10/1/13 J
10/1/13 Curious