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
 Index and identical values in column

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
Sprenger Posted - 08/23/2016 : 12:10:13 PM
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

4   L A T E S T    R E P L I E S    (Newest First)
AmandaLu Posted - 08/24/2016 : 05:04:31 AM
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
yuki_wu Posted - 08/24/2016 : 03:58:27 AM
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
Sprenger Posted - 08/24/2016 : 03:35:02 AM
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
yuki_wu Posted - 08/24/2016 : 02:14:01 AM
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

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