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
 LabTalk Forum
 Function fitting
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

66de250

China
24 Posts

Posted - 10/28/2024 :  1:07:12 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Dear Sirs,I need some assistance with a LabTalk script for nonlinear curve fitting.Below is my specific problem:
First, I have a user-defined function named ‘fuc’, which contains three parameters: "AA", "BB", and "CC". All three parameters have an initial value of '1'. Additionally, I have a dataset and a graph based on this data.
I need to implement the following using a LabTalk script:
Select a specific segment of the data in the graph (e.g., from the maximum value to the last value ) as the fitting range for nonlinear curve fitting.
Use the user-defined function file "fuc" as the fitting function.
Before each fitting, I need to change the initial value of parameter "CC".
Fit until convergence (when I manually operate, I find that may need click the "fit until convergence" button multiple times results in a correct fit, so in the script you need to consider how to ensure the fitting result is correct).
After convergence, I need to extract the fitted parameter "CC" and save it directly into a new worksheet at the i-th row and j-th column.
Could you provide me with a specific LabTalk code to solve this? Thank you very much!

YimingChen

1606 Posts

Posted - 10/28/2024 :  3:00:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Please check the following sample script to use the ExpDec1 fitting function to fit the sample data, and save the fitted parameter t1 to a new workbook. You may want to refer to the Labtalk Help page of nonlinear curve fitting:
https://www.originlab.com/doc/LabTalk/guide/Non-linear-Fitting


newbook;
wbook.dc.add("CSV");
wks.dc.source$=System.path.program$+"Samples\Curve Fitting\Gaussian.dat";
wks.dc.import();

int istart = list(max(Col(B)), Col(B)); // get the index of max y value
nlbegin iy:=(1,2)[istart:end] func:=ExpDec1 nltree:=ParamTree;
ParamTree.t1 = 5;
nlfit;

newbook;
Cell(1,1) = ParamTree.t1;


James
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