Hi,
I tried pass NLFit& to one function as input and output variable, but when pass this NLFit object as input to another funciton, seems that the result in NLFit object all are missing. So cannot pass NLFit& here.
Origin C support a better NLFit class named NLFitSession. More document and samples about this class please take a look on:
Class reference:
http://ocwiki.originlab.com/index.php?title=Category:NLFitSession_%28class%29
Sample codes:
http://ocwiki.originlab.com/index.php?title=Category:Using_NLFitSession
The following process shows how to use GetN dialog to ask continue part 2 fit or quit.
1. Copy all example codes from the following linking:
http://ocwiki.originlab.com/index.php?title=Category:NLFitSession_%28class%29
and change function prototype to bool NLFitSession_Fit_ex(NLFitSession& FitSession).
2. Add the following codes to call part 1 do fit and used the fitted parameters in part 2 fit:
#include <..\originlab\NLFitSession.h>
void part2_fit(NLFitSession& nlfit)
{
vector vParamValues, vErrors;
nlfit.GetFitResultsParams(vParamValues, vErrors);
out_str("In part2_fit function");
for(int nn=0; nn<vParamValues.GetSize(); nn++)
{
printf("P%d = %f\n", nn+1, vParamValues[nn]); // output the parameter values
nlfit.SetParamFix(nn, true); // to set parameters as fixed
}
}
void main_func()
{
NLFitSession nlfit;
NLFitSession_Fit_ex(nlfit); // do fit for part 1, all results still keep in NLNLFitSessionFit object after running
GETN_BOX(tr)
GETN_CHECK(IsContinue, "Is Continue?", 1)
while( GetNBox(tr) )// return true if click OK button
{
part2_fit(nlfit);
}
}
Iris