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 |
|
|