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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!