I WANT TO SOLVE THIS PROBLEM

1 visualización (últimos 30 días)
abduall hassn
abduall hassn el 22 de Ag. de 2015
Editada: abduall hassn el 3 de Nov. de 2016
I want select max value from very row
like this until 364

Respuesta aceptada

Walter Roberson
Walter Roberson el 22 de Ag. de 2015
[maxvals, maxidx] = max(YourMatrix, [], 2);
Now maxidx will be a vector of column numbers, one per row.
  4 comentarios
abduall hassn
abduall hassn el 23 de Ag. de 2015
Editada: Walter Roberson el 23 de Ag. de 2015
Thanx alot brother
But i want to ask. Why u give 2?
And think u again
[maxvals, maxidx] = max(YourMatrix, [], 2);
Walter Roberson
Walter Roberson el 23 de Ag. de 2015
The 2 refers to dimension #2, the columns . The above functions equivalently to
for K = 1 : size(YourMatrix,1)
[maxvals(K,1), maxidx(K,1)] = max(YourMatrix(K,:),[]);
end
If you left out the 2, then the default would be to work along the first non-singular dimension, like
for K = 1 : size(YourMatrix,2)
[maxvals(1,K), maxidx(1,K)] = max(YourMatrix(:,K),[]);
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by