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
 Writing Fit Results to Worksheet

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
hauli Posted - 10/30/2006 : 07:58:34 AM
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


1   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 10/30/2006 : 09:09:52 AM
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
}
}






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