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
 NLFitSession differs from Prompt?

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
t.n.vader Posted - 11/03/2010 : 12:22:14 AM
I have a set of 8 peaks, x- and y-coordinates in vxPeaks and vyPeaks, respectively.

2.10556	0.13497
2.25417	0.1951
2.40556	0.24147
2.54583	0.30253
2.69306	0.32074
2.83194	0.31069
2.96111	0.2639
3.09861	0.19809


When I try to fit a Guassian function through them, I receive FITITER_FAILED_MUTUAL_DEPEND errors

//	Let's fill the start fitting parameters
vector vParams(4);
vParams[0] = 0;			// y0
vParams[1] = 2.7;		// xc
vParams[2] = 0.9;		// w
vParams[3] = 0.3;		// A

//	Start fitting
NLFitSession FitSession;
if( !FitSession.SetFunction("Gauss")) {
	out_str("invalid fit function");
	exit(0);
}
if( !FitSession.SetData(vxPeaks, vyPeaks)) {
	out_str("fail to set data");
	return;
}

//	Set the parameters to start values
if( !FitSession.ParamsInitValues()) {
	out_str("fail to initialize parameters");
	return;
}
if( 0 != FitSession.SetParamValues( vParams ) ) {
	out_str("fail to set parameters");
	return;
}    
FitSession.SetParamFix(0,true); // Fix the offset to zero
FitSession.GetChiSqr();

//	Now, we fit!
int nOutcome;
if( !FitSession.Fit(&nOutcome) ) {
	printf("Fail to do fitting: %d\n", nOutcome);
	continue;
}
vector vParamValues, vErrors;
FitSession.GetFitResultsParams(vParamValues, vErrors);


However, when I just put the values in a column and then fit using Analysis -> Fitting -> Nonlinear Curve Fit -> Open Dialog, and use the same parameters and the Guass function, it succeeds with no problem.

Why does this difference occur and how do I fit in my code?
2   L A T E S T    R E P L I E S    (Newest First)
t.n.vader Posted - 11/03/2010 : 01:12:19 AM
Finally I found it, it was (ofcourse >.<) just a stupid mistake:

if( !FitSession.SetData(vxPeaks, vyPeaks)) {
should be
if( !FitSession.SetData(vyPeaks, vxPeaks)) {
t.n.vader Posted - 11/03/2010 : 12:59:53 AM
Of course, when I said Prompt, I meant Dialog...
(But when clicking 'edit' I get an error:
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'rs'
/forum/post.asp, line 663)

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