Reputation: 1827
I have a matrix with following structure
X Y ID 1 2 10 15 20 2
I want to find the index of row based on ID column. please advice me.
Upvotes: 0
Views: 741
Reputation: 1860
Use find:
find
ind = find(M(:,3) == id)
You could add 'first' or 'last' like find(M(:,3) > id, 'first').
'first'
'last'
find(M(:,3) > id, 'first')
Upvotes: 3