Getting the entry value (i,j) for the minimum value of reach row of a matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
Suppose I have a matrix
A = 3×3
11 13 15
12 14 16
32 18 21
How do I get the output (1,1) (2,1) and (1,3) which indicate the position of the minimum value of each row.
댓글 수: 0
채택된 답변
Voss
2022년 4월 9일
A=[11 13 15
12 14 16
32 18 21];
[minrow,idx] = min(A,[],2) % min value of each row, with column index
result = [(1:size(A,1)).' idx] % 18 is at (3,2) not (1,3)
추가 답변 (1개)
Arif Hoq
2022년 4월 9일
may be you are looking for this:
A=[11 13 15
12 14 16
32 18 21];
mincol=min(A) % min value of each column
minrow= min(A,[],2) % min value of each row
댓글 수: 3
참고 항목
카테고리
Help Center 및 File Exchange에서 NaNs에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!