Hi Hauli,
How about this? Add some vectors to record all the fitted parameters?
I rewrote the function, is this what you wanted?
void test()
{
// int FF;
vector vP1(20), vP2(20), vP3(20);//these vectors will record the fitted paramters.
int ii;
for (ii=1; ii<=19; ii++)
{
using NLSF = LabTalk.NLSF;
NLSF.Init();
NLSF.Begin();
NLSF.Func$="logECF";
NLSF.FitData$="Data1_B";
if (ii == 1)
{
NLSF.p1=0.3;
NLSF.p2 = ii*5;//NLSF.p2=5; ??
NLSF.p3=-3;
}
else
{
// fitted parameter value in last loop, because ii starts as 1,
//so it is not ii-1 but ii-2;
NLSF.p1 = vP1[ii-2];
NLSF.p2 = vP2[ii-2];
NLSF.p3 = vP3[ii-2];
}
NLSF.v2=0;
NLSF.IterateEx(100);
NLSF.IterateEx(100);
NLSF.ParamWks();
NLSF.PasteParams("P");
NLSF.KeepParam=1;
NLSF.End(4);
//After fitting, record the paramters.
vP1[ii-1]=NLSF.p1;
vP2[ii-1]=NLSF.p2;
vP3[ii-1]=NLSF.p3;
}
//then you can use the fitted paramters for any loop by the parameter vectors.
double aa = vP3[6];//P3 for the 7th loop.
}
But I still do not think this is a good method for the problem. If the equation is very sensitive to initial values, you'd better write a piece of initial code for the equation. You can reference a similar build-in function to write it. If you have any problem for the code, you can post your equation here and we will try to write it for you.
Zachary
OriginLab Technical Services.
Edited by - zachary_origin on 11/14/2006 04:11:19 AM