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 and identical values in column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Sprenger

Germany
15 Posts

Posted - 08/23/2016 :  12:10:13 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin 9.3.2-303:
Operating System: windows 10 x64

I am pretty new to Origin...

I try find the first occurrence of a value in a column using Index
int ind1=Index(200,col(2),1);
int ind2=Index(300,col(2),2);
ind1=;
ind2=;

This works fine if no duplicate values exist in the column. As soon as some values are present in many copies I get the ind1=-2 error message.

What alternative would work here?

Many thanks
Frank

yuki_wu

896 Posts

Posted - 08/24/2016 :  02:14:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Frank,

Index() function is used to return the row index where x occurs in a strictly monotonic dataset. You can refer to this page:
http://www.originlab.com/doc/LabTalk/ref/Index-func

In you case, I think you can try List() function. More details can be found on this page:
http://www.originlab.com/doc/LabTalk/ref/List-func

Hope it helps.

Yuki
OriginLab
Go to Top of Page

Sprenger

Germany
15 Posts

Posted - 08/24/2016 :  03:35:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear Yuki,
thanks for the reply, unfortunately, LIST cannot be used when the exact value is not present, like INDEX does.
I guess I need to use loops like this or is there yet another way?

ga = 800;
get col(A2) -e numpoints;
for(ll = 1 ; ll <= numpoints ; ll++)
{
if (Col(A2)[ll] > ga) break;
}
ll=;


Best
Frank
Go to Top of Page

yuki_wu

896 Posts

Posted - 08/24/2016 :  03:58:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Frank,

For List() function, if there is no match, the function returns 0.

FYI, List() function makes an "exact" comparison using the equal (==) operator. It means that the function returns the index number in a dataset where a specified value first occurs.

Yuki
OriginLab
Go to Top of Page

AmandaLu

439 Posts

Posted - 08/24/2016 :  05:04:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi

Please try vfind X-Function:
dataset ds;
vfind ix:=col(2) value:=300 tol:=5 ox:=ds;
ds[1]=;

And here is the detailed document of vfind function:

http://www.originlab.com/doc/X-Function/ref/vfind

Thanks,
Amanda
OriginLab Technical Service
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