[Matlab] Zeile und Spalte des größten Werts in einer Matrix bestimmen?

Neue Frage »

Calvin Auf diesen Beitrag antworten »
[Matlab] Zeile und Spalte des größten Werts in einer Matrix bestimmen?
Ich muss etwas in Matlab programmieren, bin aber noch nicht so fit drin. Gibt es eine Funktion, die mir aus einer Matrix die Zeilen- und Spaltennummer des größten Werts zurückgibt?

Beispiel:



Da "6" der größte Wert ist, brauche ich die Information "zweite Zeile, dritte Spalte".

Ich weiß, dass ich im Notfall mit Schleifen danach suchen kann. Aber da ich diese Suche sehr oft machen muss, wirken sich Schleifen negativ auf die Geschwindigkeit aus.
Dual Space Auf diesen Beitrag antworten »
RE: [Matlab] Zeile und Spalte des größten Werts in einer Matrix bestimmen?
Wenn du deine Matrix A nennst, versuch mal

code:
1:
[C,I]=max(A)


Die Stelle sollte dann im Vektor I ausgegeben werden.

Hier noch die Documentation:
Zitat:
C = max(A) returns the largest elements along different dimensions of an array.

If A is a vector, max(A) returns the largest element in A.

If A is a matrix, max(A) treats the columns of A as vectors, returning a row vector containing the maximum element from each column.

If A is a multidimensional array, max(A) treats the values along the first non-singleton dimension as vectors, returning the maximum value of each vector.

C = max(A,B) returns an array the same size as A and B with the largest elements taken from A or B. The dimensions of A and B must match, or they may be scalar.

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 (the rows) of A.

[C,I] = max(...) finds the indices of the maximum values of A, and returns them in output vector I. If there are several identical maximum values, the index of the first one found is returned.
Calvin Auf diesen Beitrag antworten »

Danke, das klingt genau nach dem, was ich suche *freu*
mat Auf diesen Beitrag antworten »
cod
matrix=[1 2 3; 4 3 6; 1 2 3]
peak=max(max(matrix))
[C,rowmaxarray]=max(matrix)
[maxvalue,colmax]=max(C)
rowmax=rowmaxarray(colmax)
Neue Frage »
Antworten »



Verwandte Themen

Die Beliebtesten »
Die Größten »
Die Neuesten »