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
 OriginC Command ERROR for USERDFINED function

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
verma Posted - 02/27/2003 : 01:02:42 AM
Hello all,
I have written the code for my function in OriginC and when I call my function from Labtalk I get the error message : COMMAND ERROR!! Can any one help me how to overcome this. I could compile the code wihtout any error message. My code goes like this

#define R 8.315
int i, d1plusd2, d1intod2, d1d1, d2d2;
double rbyt2, ed1d2byt, ed1, ed2, dr, nr, nr1, nr2, nr3;

double thamizh (string wksName, int DELTA1, int DELTA2)
{

Worksheet wks(wksName);
int rows = wks.GetNumRows();


Dataset dd1(wksName, 0);
Dataset dd2(wksName, 1);

d1plusd2 = DELTA1 + DELTA2;
d1intod2 = DELTA1 * DELTA2;
d1d1 = DELTA1 * DELTA1;
d2d2 = DELTA2 * DELTA2;

for (i = 0; i <= rows; i++)
{
rbyt2 = (R / (dd1[i] * dd1[i]));
ed1d2byt = exp(d1plusd2/dd1[i]);
ed1 = exp(DELTA1/dd1[i]);
ed2 = exp(DELTA2/dd1[i]);
dr = (ed1 + ed2 + ed1d2byt) * (ed1 + ed2 + ed1d2byt);
nr1 = -2 * d1intod2;
nr2 = d2d2 * (1 + ed1);
nr3 = d1d1 * (1 + ed2);
nr = rbyt2 * ed1d2byt * (nr1 + nr2 + nr3);

return nr/dr;



}
}

void thamizhfit (Worksheet wksData)
{
Dataset dsX(wksData, 0);
Dataset dsY(wksData, 1);

Curve crvData(wksData,0,1);

GraphPage grphData;
string strGrphTemplate = "scatter.otp";

int nOptionG = CREATE_VISIBLE_SAME;
grphData.Create(strGrphTemplate, nOptionG);
GraphLayer grphLayer= grphData.Layers();

int nPlot = grphLayer.AddPlot(crvData, IDM_PLOT_SCATTER);

grphLayer.Rescale();

//Perform nonlinear Fit to the Plotted Data

using NLSF = LabTalk.NLSF;

NLSF.PasteToPlot = 1;
NLSF.Func$ = "thamizh"; //user Defined Function
NLSF.FitWksName$ = "wksData";
NLSF.n$ = "DELTA1", "DELTA2"; //names of Input Paramters
NLSF.n1 = 1;
NLSF.n2 = 2;
NLSF.p1 = 30; //Initial Guess for the Paramter 1
NLSF.p2 = 200; //Initial Guess for the Parameter 2
NLSF.fit(50); //Number of fitting iterations

}

1   L A T E S T    R E P L I E S    (Newest First)
Laurie Posted - 02/27/2003 : 09:41:17 AM
Because you are running your 'thamizhfit' function from the Script Window, you need to pass it a string. LabTalk doesn't know about the Worksheet class. If you were calling this function from another Origin C function then it would be ok, but to call it from LabTalk the argument should be similar to the 'thamizh' function which takes a string and then within the function declares a worksheet object.

The other problem that I notice is that you've used ' NLSF.Func$ = "thamizh";'. In order for this to work, you need to have defined a new function from within the NLSF, where the name of the function is thamizh, and saved it as an FDF file.

Make sure that you have Origin 7 SR3. Check Help:Check for Updates to make sure that you have the latest update. Open the Advanced fitter by selecting Analysis:Non-linear Curve Fit:Advanced Fitting Tool. Select Function:New and define your function in Origin C by clicking the Edit in CodeBuilder button.

Any questions, let me know.

OriginLab Technical Support

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