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
 LabTalk Forum
 range in nlfit

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
scalpa Posted - 07/01/2026 : 12:00:06 PM
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
2   L A T E S T    R E P L I E S    (Newest First)
scalpa Posted - 07/02/2026 : 04:35:26 AM
works as a charm! thanks !
scalpa
ChaoC Posted - 07/01/2026 : 5:24:45 PM
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

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