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
 fitting a plot

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
moritzo 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;
}
1   L A T E S T    R E P L I E S    (Newest First)
Iris_Bai 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

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