How to get row index of certain values in a vector

5 views (last 30 days)
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.

Accepted Answer

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

More Answers (1)

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

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!