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
 linear fit with a loop
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

mej

Albania
Posts

Posted - 01/21/2004 :  12:15:28 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello

I want to fit 33 datasets with the same x values and i use this script

loop(n,1,33){
StartRange=0.5;
EndRange=0.9;
mks1=xindex(StartRange,data_a); // data_a is the x value
mks2=xindex(EndRange,data_a);
doc -uw;
lr data_int$(n); // data_int$(n) is the y values
};

But the result is not correct

Mike Buess

USA
3037 Posts

Posted - 01/21/2004 :  3:36:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
1. mks1 and mks2 are usually reserved for use with the data selector tool. When using lr in a loop it's probably better to specify the range on the command line as shown below.
2. xindex uses a Y dataset as the argument, not the X dataset. Since the X values are shared by all Y datasets you only need to get the start and stop indices once.

StartRange=0.5;
EndRange=0.9;
i1=xindex(StartRange,data_int1);
i2=xindex(EndRange,data_int1);
loop (n,1,33) {
lr data_int$(n) -b i1 -e i2;
type $(n): $(lr.a), $(lr.b); // dataset #: intercept, slope
};

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 01/21/2004 6:32:53 PM
Go to Top of Page

mej

Albania
Posts

Posted - 01/22/2004 :  11:07:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It is OK but the linear fit does not appear in the graphs previously ploted in each graph
Thanks
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