Author |
Topic  |
|
moritzo
1 Posts |
Posted - 11/05/2008 : 4:18:09 PM
|
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
|
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 |
 |
|
|
Topic  |
|
|
|