MATLAB Answers

how to find min or max value in each row of a matrix and its index, if a matrix is 3x2 it will find the min in first row

조회 수: 1,502(최근 30일)
R= [27 25 21; 35 38 37; 42 47 49]; 1st min value will be 21

  댓글 수: 0

로그인 to comment.

채택된 답변

Mischa Kim
Mischa Kim 7 Nov 2017
편집: Mischa Kim 7 Nov 2017
Use
[val,loc] = min(R')
val =
21 35 42 % min value in each row
loc =
3 1 1 % column location of min value

  댓글 수: 4

표시 이전 댓글 수: 1
Mischa Kim
Mischa Kim 7 Nov 2017
[val,loc] = min(R(1,:)) % min value in 1st row
val =
21
loc =
3
Replace the "1" in the min command by a running index to step through each row, e.g., using a loop.
Fahim MUMAND
Fahim MUMAND 14 Oct 2019
suppose a matrix R = ones(4,4)
Every element is maximum and minimum, how to extract their indices?
How to extract the indices of max or min if there are more than 1 in col and in row?

로그인 to comment.

추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.

태그


Translated by