필터 지우기
필터 지우기

help how can I find the minimum number and return it's index in each row?

조회 수: 2 (최근 30일)
help how can I find the minimum number and return it's index in each row?
  댓글 수: 1
maha ismail
maha ismail 2014년 11월 13일
I have a matrix not a vector and I need the minimum value except 0 and position of minimum value in each row

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

채택된 답변

Manoj
Manoj 2014년 11월 13일
a=[8,2,3,4,5];
[b,ix]=min(a);
ix gives you the positions and b gives the minimum value
  댓글 수: 4
maha ismail
maha ismail 2014년 11월 13일
sorry dear I have a matrix not a vector I have a positive number and 0 I need to find the minimum value except 0 and I need to return the position of minimum value in each row ..but my program is not run..
maha ismail
maha ismail 2014년 11월 13일
dear manoj thanks alot for help me its a perfect solution but I need another update if the matrix has a zero value and the zero is the smallest value but I don't choose it I need more than zero and the smallest after zero

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

추가 답변 (1개)

Guillaume
Guillaume 2014년 11월 13일
To find the minimum of a row, use:
min(m, [], 2)
Probably, the simplest way to ignore 0s is to replace them with NaNs before calling min.
m(m == 0) = nan;
[mval, mcol] = min(m, [], 2);

카테고리

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