Find the under condition min or max of a row vector

조회 수: 16 (최근 30일)
SOUGLES STAMATIS
SOUGLES STAMATIS 2021년 1월 11일
댓글: KSSV 2021년 1월 11일
Assume that you have a row vector a = [ 1 3 5 2 5 7 8 3 6 4 9 ] . I want to find in which colomn there is the min value of this vector but under condition that this min value is >= 3 . Can enyone help?

채택된 답변

KSSV
KSSV 2021년 1월 11일
a = [ 1 3 5 2 5 7 8 3 6 4 9 ] ;
a(a<3) = NaN ; % Replace values <3 to NaN
[val,idx] = min(a)
  댓글 수: 5
SOUGLES STAMATIS
SOUGLES STAMATIS 2021년 1월 11일
편집: SOUGLES STAMATIS 2021년 1월 11일
that returns the actual values ( 3 and 5 ). I need the column number ( 4 and 9 in this case)
KSSV
KSSV 2021년 1월 11일
find(~isnan(a),1,'first')
find(~isnan(a),1,'last')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by