MATLAB: How to get row index of certain values in a vector

equalsindexingMATLABvector

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.

Best Answer

Use find() instead:
rows = find(obj.GanttM(:,2)==i);