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
 Index() Function Question
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cdrozdowski111

USA
247 Posts

Posted - 03/18/2013 :  7:22:51 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
OriginPro 9.0.0 SR1, Win7 64-bit, running in VMware Fusion 5.0.2

I am doing something wrong with the LT Index() function. Given a worksheet as shown in the attached pic, why would the following lines of code all return -1?


double nIdx1 = index(11781.20, Col(1)); type -a $(nIdx1); // Returns -1
double nIdx1 = index(11781.00, Col(1), 1); type -a $(nIdx1); // Returns -1
double nIdx1 = index(11781.00, Col(1), 2); type -a $(nIdx1); // Returns -1


Penn

China
644 Posts

Posted - 03/18/2013 :  11:26:54 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

This is a bug for the monotonic decreasing data. You can try the xindex function to see whether it can work fine for your need. Such as:

// the second parameter is Col(2), but not Col(1) here
double nIdx1 = xindex(11781.20, Col(2)); type -a $(nIdx1); // Returns -1
double nIdx1 = xindex(11781.00, Col(2), 1); type -a $(nIdx1); // Returns -1
double nIdx1 = xindex(11781.00, Col(2), 2); type -a $(nIdx1); // Returns -1


Penn
Go to Top of Page

cdrozdowski111

USA
247 Posts

Posted - 03/19/2013 :  04:56:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I tried xindex and it worked. But the docs indicate that the X column must be in ascending order, so I didn't want to rely on it in case the behavior changed down the road to match the docs.

http://wiki.originlab.com/~originla/ltwiki/index.php?title=LabTalk:Xindex_%28function%29

So, what I am doing is to reverse all of the columns in the worksheet, use the index() function, do my operations, and then reverse the columns again.


range rng = [Book1]1;
colreverse rng:=[Book1]1!(1, $(rng.ncols));
double nIdx1 = index(11781.20, Col(1));

... Do operations

colreverse rng:=[Book1]1!(1, $(rng.ncols));
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