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 for Programming
 Forum for Origin C
 mathtool syntax in Origin C

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
LC_ Posted - 06/04/2013 : 11:24:44 AM
Origin Ver. and Service Release (Select Help-->About Origin): 8.5.0 SR1
Operating System: Win 7

Hi
I'm implementing a call to the mathtool fnction in an Origin C routine, but currently I'm not getting the expected results. The routine below is part of a larger routine therefore I only pasted the relevant part below (all variables are OK upon inspection). I'm expecting the result of the curve math to be put into 1st and 2nd columns of WksOut via xy_O XYRange, but the option oy:=xy_O apparently has no effect if activated.

If I comment this line:

xfmath.SetArg("oy", xy_O); //should put results into xy_O, but doesn't

the math is performed and the result is put into a new worksheet, contrary to what the Help file suggests(according to the help, via script the default output should be <input>). If activated, xy_O is returned blank.

Also, if I don't specify properly what xy_O should be as in:

xy_O.SetData(&vx_O, &vy_O);

the x-function won't run with error (24). Therefore I would expect to get the results in the right columns, but all I get is an empty xy_O range in return. Where's the error?


Thanks in advance

ps: the help doesn't specify the syntax for the operator, operand and common options, but I think I got it by trial and error (see comments below).

Extract of code:

XYRange xy_B; //baseline range
XYRange xy_S; //data to be subtracted from baseline
XYRange xy_O; //output

Column cx_O(WksOut,0); //WksOut is an existing worksheet where the results should be put in
Column cy_O(WksOut,1); //columns 0 and 1 exist in WksOut

vector<double>& vx_O = cx_O.GetDataObject(); //vx_O
vector<double>& vy_O = cy_O.GetDataObject();

//defines input and output ranges
DataPlot dp_B = gl.DataPlots(0); //gl is the active graph layer, 1st curve is baseline
dp_B.GetDataRange(xy_B);
DataPlot dp_S = gl.DataPlots(1); //2nd curve contains data to be subtracted
dp_S.GetDataRange(xy_S);
xy_O.SetData(&vx_O, &vy_O);

//X-Function call
XFBase xfmath("mathtool");
xfmath.SetArg("iy1", xy_S);
xfmath.SetArg("operator", 1); //assuming 1 is code for subtract
xfmath.SetArg("operand",1); //assuming 1 is code for reference data
xfmath.SetArg("iy2", xy_B);
xfmath.SetArg("oy", xy_O); //should put results into xy_O, but doesn't
xfmath.SetArg("common",1); //assuming 1 is code for common range only
xfmath.Evaluate();
2   L A T E S T    R E P L I E S    (Newest First)
LC_ Posted - 06/06/2013 : 08:16:11 AM
Thanks very much, Penn! It works great now. I had tried this path, but was doing something wrong on the way.
Penn Posted - 06/06/2013 : 05:43:47 AM
Hi,

It works if I change to the following way.

XYRange xy_B;	//baseline range
XYRange xy_S;	//data to be subtracted from baseline
//XYRange xy_O;	//output

//Column cx_O(WksOut,0); //WksOut is an existing worksheet where the results should be put in
//Column cy_O(WksOut,1); //columns 0 and 1 exist in WksOut

//vector<double>& vx_O = cx_O.GetDataObject(); //vx_O 
//vector<double>& vy_O = cy_O.GetDataObject();
DataRange dr;
dr.Add(WksOut, 0, "X");
dr.Add(WksOut, 1, "Y");
XYRange xy_O(dr);

//defines input and output ranges	
DataPlot dp_B = gl.DataPlots(0); //gl is the active graph layer, 1st curve is baseline
dp_B.GetDataRange(xy_B);
DataPlot dp_S = gl.DataPlots(1); //2nd curve contains data to be subtracted
dp_S.GetDataRange(xy_S);
//xy_O.SetData(&vx_O, &vy_O);	

//X-Function call
XFBase xfmath("mathtool");	
xfmath.SetArg("iy1", xy_S);	
xfmath.SetArg("operator", 1); //assuming 1 is code for subtract
xfmath.SetArg("operand",1); //assuming 1 is code for reference data
xfmath.SetArg("iy2", xy_B);
xfmath.SetArg("oy", xy_O); //should put results into xy_O, but doesn't
xfmath.SetArg("common",1); //assuming 1 is code for common range only	
xfmath.Evaluate();


Penn

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