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
 NLFitSession differs from Prompt?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

t.n.vader

Netherlands
Posts

Posted - 11/03/2010 :  12:22:14 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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?

t.n.vader

Netherlands
Posts

Posted - 11/03/2010 :  12:59:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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)
Go to Top of Page

t.n.vader

Netherlands
Posts

Posted - 11/03/2010 :  01:12:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Finally I found it, it was (ofcourse >.<) just a stupid mistake:

if( !FitSession.SetData(vxPeaks, vyPeaks)) {
should be
if( !FitSession.SetData(vyPeaks, vxPeaks)) {
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