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
 fitting a plot
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

moritzo

1 Posts

Posted - 11/05/2008 :  4:18:09 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin 7.5, windows XP

I have a function which is supposed to create a plot and then use NLSF to generate a fit. The problem I am running into is that the fit always replaces the original plot and I can't seem to get them to both show up. By the end of the fitting the orignal data curve has always been replaced and I can't seem to add it after the fact to the plot. I appreciate any suggestions The code is below:

vector fitter(Curve temp_data, int downRange, int upRange, string func)
{ //pass to this function the curve to be fit with the range and the fitting function and it will return
//creates a visible plot

GraphPage TET; //Graphs results of fits
GraphLayer TOT;
DataPlot TAT;

vector params(10);
string data_name;

using NLSF = LabTalk.NLSF; //NLSF is the fitting engine
NLSF.Init(); // initialize fitter
NLSF.PasteToPlot = 1; // turn off pasting results to graph
NLSF.Func$ = func; // assign fitting function
NLSF.numReplica=0;

temp_data.GetName(data_name);
TET.Create(NULL, CREATE_TEMP);
TOT=TET.Layers(0);
set_active_layer(TOT);
TOT.AddPlot(temp_data);
TAT=TOT.DataPlots(0);
TOT.Rescale();
TET.Rename(temp_data.GetName());
TAT.SetRange(downRange,upRange); //Sets the range of the fitting

NLSF.begin();
NLSF.cleanUpFitData();
NLSF.msgPrompt=0;

NLSF.FitData$ = data_name; // assign fitting dataset
NLSF.dataBegin=downRange;
NLSF.dataEnd=upRange;
NLSF.Execute("parainit"); // perform auto parameter initialization
NLSF.Fit(300); // perform fit

params[0]=NLSF.P1;
params[1]=NLSF.P2;
params[2]=NLSF.P3;
NLSF.pasteParams("P");
NLSF.end(13);
NLSF.unInit();
// TET.Show(FALSE);
TET.Detach();
return params;
}

Iris_Bai

China
Posts

Posted - 11/11/2008 :  10:52:31 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Please change your function fitter phototype "Curve temp_data" to "Curve& temp_data", add & after Curve, and try again.

If NOT add &, pass Curve will do copy a Curve as temp and then pass to function, you can print data_name to see, the name begining with "TMP_".
If added &, the name will be real name from data.

Iris
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