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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 FFT data using Origin C in Code Builder
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

thebigpeeler

United Kingdom
11 Posts

Posted - 06/26/2013 :  09:12:32 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Sam Fang

292 Posts

Posted - 06/27/2013 :  05:29:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
fft1 is an X-Function. You can call it in Origin C. You can see following documents:
1. Calling X-Functions in Origin C
http://wikis/ocwiki/index.php?title=OCGuide%3ACalling_X-Functions_in_Origin_C

2. fft1 X-Functions
http://wikis/wiki2/index.php?title=X-Function%3AFft1


-----------------------------------------
Origin C also provides a basic function:
int fft_fft_real( int iSize, double * vSig, FFT_SIGN iSign = FFT_FORWARD )

You have to use other functions for derived results.

Sam
OriginLab Technical Services

Edited by - Sam Fang on 06/27/2013 05:30:02 AM
Go to Top of Page

thebigpeeler

United Kingdom
11 Posts

Posted - 06/27/2013 :  05:41:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

thebigpeeler

United Kingdom
11 Posts

Posted - 06/27/2013 :  06:14:11 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
if i remove the argument completely, it works, whats going wrong?

:D
Go to Top of Page

thebigpeeler

United Kingdom
11 Posts

Posted - 06/27/2013 :  06:56:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Sam Fang

292 Posts

Posted - 06/27/2013 :  11:45:02 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

thebigpeeler

United Kingdom
11 Posts

Posted - 06/28/2013 :  05:10:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thats even more awesome haha cheers man solved!

:D
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000