필터 지우기
필터 지우기

Find the row number of element that meets the condition

조회 수: 38 (최근 30일)
Prasad Raut
Prasad Raut 2019년 2월 15일
댓글: Prasad Raut 2019년 2월 15일
I am trying to use find command to locate row number of the first elements which meets the condition.
All I am able to do right now is to find elements themselves which meet the condition I gave.
How can find the row number (in matrix A) which meets the condition first. I wanted to use this row number further find relevant element value from another array.
for example:
A=[450;470;490;510;530;550;570];
B=[10;20;30;40;50;60;70];
so if I use condition A>500 , answer would be 40.
I tried using following command
C=A(A>500)
but it is giving me all the values of element and not row number, which further will be used to find element from B array having same row number.

채택된 답변

madhan ravi
madhan ravi 2019년 2월 15일
index=find(A>500,1,'first')
B(index)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by