Author |
Topic  |
|
thebigpeeler
United Kingdom
11 Posts |
Posted - 06/26/2013 : 09:12:32 AM
|
Hi guys,
So basically im writing some code using Origin C to speed up some data analysis. I have my Data in Time(X) and Amplitude in Volts (Y), using origin pro id usually go to Analysis->Signal Processing->FFT->FFT
Then id select the Amplitude column as the input, tick shift and unwrap phase,normalize the power to MSA and plot Amplitude/Phase.
Is there any way to do this in code? I've successfully managed to create new worksheets automatically and I understand how to move data from one sheet to another, but have no idea how to perform FFT like I would normally do manually, but in code. All i need is 3 columns as the output; Freq, Amplitude and Phase.
Thanks in advance guys
Oli
:D |
|
thebigpeeler
United Kingdom
11 Posts |
Posted - 06/26/2013 : 09:33:17 AM
|
or is there any way of calling fft1 with its options from the Origin c code? that would be perfect, especially if i can extract the data from the call
:D |
 |
|
Sam Fang
293 Posts |
|
thebigpeeler
United Kingdom
11 Posts |
Posted - 06/27/2013 : 05:41:05 AM
|
Cheers man, im trying to get fft1 to work but coming up with the foillowing error when i execute my code:
fft1:X-Function failed to execute! Internal error code: -898, -45
my code is here:
void CallFFT() { // Load the X-Function string strXFNameToCall = "fft1"; XFBase xf(strXFNameToCall); if( !xf.IsValid() ) { out_str("Failed to load xfunction."); return; } // Set the arguments for the X-Function
string strFilename = "Col(1)"; if( !xf.SetArg("ix", strFilename) ) out_str("Failed to set argument filename"); // With arguments set we can now execute the X-Function if( !xf.Evaluate() ) { out_str("Failed to evaluate the getnlr X-Function."); return; } }
:D |
 |
|
thebigpeeler
United Kingdom
11 Posts |
Posted - 06/27/2013 : 06:14:11 AM
|
if i remove the argument completely, it works, whats going wrong?
:D |
 |
|
thebigpeeler
United Kingdom
11 Posts |
Posted - 06/27/2013 : 06:56:32 AM
|
also, all the other arguments work fine, its only the ix input argument i cant seem to get right, is the following syntax correct?
[Book1]myData!3
:D |
 |
|
Sam Fang
293 Posts |
Posted - 06/27/2013 : 11:45:02 PM
|
ix is a complex vector, not a string. There is a bug for SetArg function with vector.
You can also call X-Function using LabTalk in OriginC.
BOOL rc;
rc = LT_execute("fft1 ix:=col(1);");
Sam OriginLab Technical Services |
Edited by - Sam Fang on 06/28/2013 01:59:38 AM |
 |
|
thebigpeeler
United Kingdom
11 Posts |
Posted - 06/28/2013 : 05:10:13 AM
|
thats even more awesome haha cheers man solved!
:D |
 |
|
|
Topic  |
|