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
 Writing Fit Results to Worksheet
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hauli

Austria
Posts

Posted - 10/30/2006 :  07:58:34 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System: windows XP

Dear all,

the following script loops over all existing worksheets, performs a NLSF fit and then creates a worksheet named "Results", where in the first column the names [vWksName] are written.
the problem is now, how to write the values of NLSF.p3 (for each fit)in the second column. So the fitting results of (lets say 4) fits should be written into the newly created worksheet "Results".

void test1()
{
uint iWksCount = Project.WorksheetPages.Count();
vector<string> vWksName(iWksCount);
int ii=0;
foreach (WorksheetPage pg in Project.WorksheetPages)
{
vWksName[ii++] = pg.GetName();
}
for (ii=0; ii<iWksCount; ii++)
{
Worksheet wks= vWksName[ii];
Curve crvData(wks, 0, 1);

GraphPage gpg;
gpg.Create("C:\Documents and Settings\Sunrise NRU.OTP");
gpg.Rename("Graph"+vWksName[ii]);//name Graph after Condensate
GraphLayer gly = gpg.Layers();
gly.AddPlot(crvData, IDM_PLOT_SCATTER);
gly.Rescale();

using NLSF = LabTalk.NLSF;
NLSF.Init();
NLSF.PasteToPlot(0);
NLSF.Func$="DoseResp";
NLSF.FitData$=crvData.GetName();
NLSF.Execute("parainit");
NLSF.p1=0;
NLSF.p2=100;
NLSF.p3=1.5;
NLSF.p4=-3;
NLSF.IterateEx(100);
NLSF.ParamWks("Param"+vWksName[ii]);
NLSF.End(4);
}

Worksheet wksResults;
wksResults.Create("C:\Documents and Settings\SunriseResults.otw");
wksResults.GetPage().Rename("Results");

int i=0;
for (i; i<iWksCount; i++)
{ wksResults.SetCell(i, 0, vWksName[i])
}

}

Thanks in advance
Hauli


easwar

USA
1965 Posts

Posted - 10/30/2006 :  09:09:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Hauli,

Just need to create result wks before the fitting loop, and write results to this wks inside the loop instead of outside?

Try this...see comments for details...


void test1()
{
uint iWksCount = Project.WorksheetPages.Count();
vector<string> vWksName(iWksCount);
int ii=0;
foreach (WorksheetPage pg in Project.WorksheetPages)
{
vWksName[ii++] = pg.GetName();
}

// Create result worksheet here
Worksheet wksResults;
wksResults.Create("C:\Documents and Settings\SunriseResults.otw");
wksResults.GetPage().Rename("Results");
// Make sure your result worksheet has enough cols to hold all parameter values
// If not, add new columns using worksheet AddCol method here


for (ii=0; ii<iWksCount; ii++)
{
Worksheet wks= vWksName[ii];
Curve crvData(wks, 0, 1);

GraphPage gpg;
gpg.Create("C:\Documents and Settings\Sunrise NRU.OTP");
gpg.Rename("Graph"+vWksName[ii]);//name Graph after Condensate
GraphLayer gly = gpg.Layers();
gly.AddPlot(crvData, IDM_PLOT_SCATTER);
gly.Rescale();

using NLSF = LabTalk.NLSF;
NLSF.Init();
NLSF.PasteToPlot(0);
NLSF.Func$="DoseResp";
NLSF.FitData$=crvData.GetName();
NLSF.Execute("parainit");
NLSF.p1=0;
NLSF.p2=100;
NLSF.p3=1.5;
NLSF.p4=-3;
NLSF.IterateEx(100);
//
// put in another iterateex statement to ensure converegence
// this is equivalent to clicking the 100Iter button another time in the GUI
NLSF.IterateEx(100);
//
//
NLSF.ParamWks("Param"+vWksName[ii]);
NLSF.End(4);

// Write wks name and parameters to result worksheet here
wksResults.SetCell(ii, 0, vWksName[ii]);
// now parameters
wksResults.SetCell(ii, 1, NLSF.p1);
wksResults.SetCell(ii, 2, NLSF.p2);
// etc, for other parameters
}
}





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