How to get row index of certain values in a vector

37 次查看(过去 30 天)
I am looking for a way to extract the row index of certain values from a vector.
I tried with
[ ~ , index ] = max(obj.GanttM(:,2)==i);
This only gives me one index but the number i appears several times. How can I extract all row indeces with one command?
Thank you.

采纳的回答

Image Analyst
Image Analyst 2013-12-28
Use find() instead:
rows = find(obj.GanttM(:,2)==i);

更多回答(1 个)

Amit
Amit 2013-12-28
index = find(obj.GanttM(:,2)==i)
this will do it!

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by