Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Derek Goring

Posts: 3,892
Registered: 12/7/04
Re: Phase Angle Plot of fft
Posted: Oct 1, 2013 3:54 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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?



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.