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
 questions with xindex

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
circumvent Posted - 06/01/2009 : 4:35:25 PM
Origin Ver. and Service Release (Select Help-->About Origin): 8.0 SR3
Operating System: Vista

Hi,

I have a question with the labtalk function xindex, it seems that it does not work as it supposed to be.

A quick example, I have XY dataset
X Y
1 3
2 4
3 7
4 10
5 11

The following command will give

a=xindex(3,book1_b);
a=; #a=3 Should it be 1 since it's the first row?

a=xindex(4,book1_b);
a=; #a=4 Should it be 2 since it's the second row?

a=xindex(5,book7_b);
a=; #a=5

a=xindex(6,book7_b);
a=; #a=5

3   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 06/03/2009 : 11:11:21 PM
There is a Table function that you can use, but you must have another column that contains index, which seems to be the case as shown in your ealier code

a=int(table(book1_b, book1_a, x))

It seems that the Table function was not documented in Origin 8, but here is the info

y = Table(sx, sy, x)

where sx is the dataset name of the independent vector and sy the dependent vector and it interpolates sy vs sx to find y-value at given x-value.

CP
circumvent Posted - 06/01/2009 : 5:54:03 PM
Hi Tony,

Thanks for you reply, but list(value, dataset) is not working because I am not looking for the exact value. I hope the function could return the index of the data equal or smaller than value.

For the xindex, even I only have one column with dataset
0.1
0.2
0.3
1.2
1.2
3
3.5
5.1
5.2


The command
a=xindex(3,book1_b);
a=; will give 3 again. Something must be wrong here.
artem Posted - 06/01/2009 : 5:26:32 PM
xindex looks at the values of x, not y. Use list(value, dataset) to get the index of the first cell in dataset that is equal to value.

From the Help file:
"The list(value, dataset) function returns the index number in dataset where value first occurs. If there is no match, the function returns 0. Note that this function makes an “exact” comparison using the equal (==) operator."

Tony

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