The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum
 Origin Forum
 Puzzle about the FFT phase angle, an error?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
natie Posted - 12/02/2011 : 06:19:34 AM
Found some inconsistence on FFT.

Perform FFT on a time series, and I obtained serveral collumn data such as real part, imaginary part, and phase, as a result. Then I use the real and imginary parts to calcualte the phase angle, but the calucated one is diffrent from the Origin result.

FFT options: without unwrap phase, resulting a angle between -180 to 180 degree.

I calculate the phase using equation of "atan(col(imag)/col(real))*180/pi", according to the Origin FFT algorithm.




7   L A T E S T    R E P L I E S    (Newest First)
Drbobshepherd Posted - 01/27/2012 : 6:27:46 PM
Hey, I just noticed in OriginPro 8.6 that LabTalk has added Atan2() to the command set. That is great! I know there are many like me that need to use Atan2(), instead of Atan(), for calculating polar angles because the range for Atan2() spans a complete cycle (360 degrees) while the range for Atan() only spans half of a cycle (180 degrees).

The LabTalk command Angle() also has a full cycle range, but Atan2() is more well-known. Atan2() can be found in C, C++, C#, Visual Basic, Excel, MatLab, JAVA, and PHP codes.

Atan2() is the superior choice for natie's problem for two reasons:
1. The range for atan2() is from -pi to pi, which is easily converted to degrees without the need for conditional testing.
2. atan2() is defined at the origin (0,0); angle() is not and this can cause errors.

Note: The conventional usage of atan2 is atan(y,x), where the y is the vertical component, and x is the horizontal. This is so the order of the input data pair (x,y) remains the same for both atan() and atan2(), for you see, atan2(y,x)=atan(y/x) where the range is from -pi/2 to pi/2. I wish I had a nickel everytime a programmer suddenly realized he had to replace his "atan(y/x)" commands with "atan2(y,x)".

By the way, Excel has reversed the order, but Origin has it right. Congatulations, guys.
Sam Fang Posted - 12/07/2011 : 10:20:24 PM
Thanks, Drbobshepherd.

We can use following script to return an angle between -180 to 180.

col(imag)<0?angle(col(real),col(imag))/pi*180-360:angle(col(real),col(imag))/pi*180


Sam
OriginLab Technical Services
Drbobshepherd Posted - 12/07/2011 : 12:46:47 PM
Instead of atan(imag,real), try angle(real, imag); this is the LabTalk version of atan2. Then convert the result from radians to degrees.
Sam Fang Posted - 12/07/2011 : 06:07:22 AM
Phase angles agree only for Real>0 if you use atan.

Sam
OriginLab Technical Services
natie Posted - 12/07/2011 : 05:50:20 AM
Sam, thank you for your reply.


Yes the difference results from the range of "atan" function.
but it is interesting as the attaced figures show:

our wave has a frequency of 70Hz, and the phase angle calculated by both method is identical, i.e.at 70Hz. At the triple frequency 210Hz, we get a similar result,but contary at a double frequency,140Hz. Obvious difference is found at the rest frequnecies.


Listed is FFT result by Origin 8.5, and the comparasion figure about phase angle of both calcualtion method.

FFT result:


Comparasion of phase angele produced by Origin and direct calculation by real and imaginary part:


It seems, I have gotten a consistant result since both method can produce the same phase angle at a interested frequency. But I don't know the exact reason for these result. And what does it means for the phase angles at the rest frenquecies?

Below is the wave file we used:
http://www.originlab.com/ftp/forum_and_kbase/Images/wave.txt

Thank you for your consideration of this problem.

Natie
Sam Fang Posted - 12/04/2011 : 10:30:49 PM
I can't reproduce your problem.

Note that you can't simply use "atan(col(imag)/col(real))*180/pi" to calculate the phase because atan only ranges from -pi/2 to pi/2, i.e. -90 to 90. You need also check the sign of real and imag.

To reproduce your problem, you need tell us your Origin's version and send us your project file. To upload a file, click Send File to Tech support button at the top right of the forum.

Thanks.

Sam
OriginLab Technical Services
natie Posted - 12/02/2011 : 06:25:48 AM
Ok, I cannot upload any file...



The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000