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
 range in nlfit
 New Topic  Reply to Topic
 Printer Friendly
Author  Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

scalpa

France
Posts

Posted - 07/01/2026 :  12:00:06 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 2026
Operating System:win11

Hello,
I am trying to set a range before performing a nlfit. to clarify, we can take the origin example:

fname$=system.path.program$ + "Samples\Curve Fitting\Exponential Growth.dat"; // prepare data
newbook;
impasc;
wks.addcol();
string strData$ = %(%H,$(wks.ncols)); // Remember the name of the added column
range fitx=1, fity=3;
plotxy (1,2);
nlbegin 1 ExpGrow1 tt; // initialize fitting session for the first plot using ExpGrow1 function
tt.x0=0;tt.f_x0=1; // first fix the x0 value at that initial date
tt.y0=0;tt.f_y0=1; // also fix y0
tt.A1=1;
nlfit 3; // do only 3 iterations
tt.f_x0=0;tt.f_y0=0; // then relax the x0 and y0 to fit with default max iterations
nlfit;
fity=fit(fitx); // now we can generate the fit curve
nlend; // all don
layer -i %(strData$); // Include the fit in the plot
set %(strData$) -c 2; // Set its color to red

I would like to compute the fit only for 0.6 < x < 1.4. I've tried different things with the range command but couldn't get it right. can someone help me ? thanks !
Best,
Scalpa

ChaoC

USA
239 Posts

Posted - 07/01/2026 :  5:24:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Scalpa,

Try this for example:

fname$=system.path.program$ + "Samples\Curve Fitting\Exponential Growth.dat"; // prepare data
newbook;
impasc;
wks.ncols=4;
wks.col3.type=4;
string strData$ = %(%H,$(wks.ncols)); // Remember the name of the added column
range fitx=1[x.6:1.4], fitx2=3, fity=4;
plotxy (1,2);
nlbegin 1 ExpGrow1 tt; // initialize fitting session for the first plot using ExpGrow1 function
tt.x0=0;tt.f_x0=1; // first fix the x0 value at that initial date
tt.y0=0;tt.f_y0=1; // also fix y0
tt.A1=1;
nlfit 3; // do only 3 iterations
tt.f_x0=0;tt.f_y0=0; // then relax the x0 and y0 to fit with default max iterations
nlfit;
fity=fit(fitx); // now we can generate the fit curve;
fitx2=fitx;
nlend; // all don
layer -i %(strData$); // Include the fit in the plot
set %(strData$) -c 2; // Set its color to red


range fitx=1[x.6:1.4]
means column 1 x-values from 0.6 to 1.4.
range fitx=1[30:80]
means column 1 row index from 30 to 80.

See: https://docs.originlab.com/labtalk/guide/range-notation/#Specifying_Subrange_Using_X_Values

Best,
Chao
Go to Top of Page

scalpa

France
Posts

Posted - 07/02/2026 :  04:35:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
works as a charm! thanks !
scalpa
Go to Top of Page
   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