How to get row index of certain values in a vector

조회 수: 40 (최근 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 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