position of maximum in matrix

조회 수: 10 (최근 30일)
fatima
fatima 2012년 7월 10일
Hi,
I'm going to find the position of maximum value in every column of a matrix

답변 (3개)

John
John 2012년 7월 10일
편집: John 2012년 7월 10일
Let's say
A = [1 2 3; 4 5 6; 7 8 9];
[row,columns] = size(A); index_matrix = zeros(1,columns)
for i = 1:columns
[large,index] = max(:,i);
index_matrix(i) = index;
end
%The index_matrix vector should store the position of the max value of each column

per isakson
per isakson 2012년 7월 10일
Help says:
C = max(A,[],dim) returns the largest elements along the dimension
of A specified by scalar dim. For example, max(A,[],1) produces the
maximum values along the first dimension of A.

Andrei Bobrov
Andrei Bobrov 2012년 7월 10일
M - matrix, please read here.
[value,index] = max(M);

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by