How to get row index of certain values in a vector

38 ビュー (過去 30 日間)
Daniel
Daniel 2013 年 12 月 28 日
コメント済み: Image Analyst 2018 年 7 月 29 日
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 件のコメント
Image Analyst
Image Analyst 2018 年 7 月 29 日
Start a new question. Attach your data and code there, after you read this.

サインインしてコメントする。

その他の回答 (1 件)

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by