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
 Origin Forum
 NonLinear Curve Fitting Param Init Script
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ckyu

Canada
2 Posts

Posted - 07/02/2014 :  5:21:33 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin):
Origin 9.1.0
Operating System: Windows 7

Hello,
I am trying to create an analysis template using NLFit.

Background
I have three parameters: a, b, and g. a and b are varying, but g is a fixed number.

Purpose
I am running an Automation Server in Excel. I plan on performing Batch Processing using VBA or executing LabTalk Commands (if this is possible) using oApp.Execute. oApp, being an instance of the Origin Application.

Requirement
I need to have it so g is set to a fixed variable read from the Origin Worksheet.

Attempt
I tried to do the following in the Parameter Init tab of the NLFit window, but it did not work:

range ry = [Data]Sheet1!Col(2)
g = ry[1] // set g to row 1, col 1 of Sheet1 in Data Wbk


I also need to set it so g is fixed.

Alternative
I understand I can do this easily in the command window using LabTalk, but if I execute curve-fitting in LabTalk, Origin does not let me save it as an Analysis Template and I cannot do any Batch Processing.
If anyone knows a way to create an Analysis Template or any Origin Document Type that automatically runs a series of LabTalk commands, that will be great.

Thank you very much for your help.

Edited by - ckyu on 07/02/2014 5:58:59 PM

jasonzhao

China
262 Posts

Posted - 07/03/2014 :  08:59:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
Please try this way for fitting with Analysis Template, the Fitting function is created with Origin C.

After defining variables and the function body, we should insert code below in the function body and initialization code, to set one parameter fixed and get values from the Origin Worksheet. Here’s the example code which defines the parameter w follows the first cell in Book1 col(a):
Dataset ds("Book1", 0);
w = ds[0];

Then, you can conduct the nonlinear fit with this fitting function and save workbook as an analysis template, which can be used in batch process.
For further questions in fitting, don’t hesitate to contact us by mail: tech@originlab.com with your data and .fdf Function file.

Best regards,
Jason Zhao
OriginLab Tech Service

Edited by - jasonzhao on 07/03/2014 09:02:50 AM
Go to Top of Page

ckyu

Canada
2 Posts

Posted - 07/03/2014 :  12:25:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I added those lines to the Origin C Fitting Function, but it unfortunately does not initialize the variable.
I did:
Dataset ds("Book1", 1);
g = ds[0];
//function here

to initialize g to the first value in the 2nd column of Book1.

When performing fitting, I got this error:
Fit did not converge - Parameter(s) g are not properly initialized. Please check and correct their values.



The only way I got it to work is if I delete g from the parameters and declare it like so:

double g;
Dataset ds("Book1", 1);
g = ds[0];
//function here


Since NLFit does not accept a blank: "--" in the value field and g is a constant.

Thank you for the help, jasonzhao!

Edited by - ckyu on 07/03/2014 1:06:09 PM
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