Get the position of the max and min values of a variables

1 visualización (últimos 30 días)
Hi, so I want the position of the maximun values of a variable my code is:
pos = 1:numel(lat1);
b = maxk(lat1,5);
% index = pos(b);
When I use the line of code indez = pos(b) I get the following error:
Array indices must be positive integers or logical values.
I dont get why. Can somebody help me?

Respuesta aceptada

Stephen23
Stephen23 el 2 de Feb. de 2022
[b,index] = maxk(lat1,5);
% ^^^^^ the second output is the index
  1 comentario
flashpode
flashpode el 2 de Feb. de 2022
Editada: Walter Roberson el 31 de Jul. de 2022
Darn I feel bad cos both answer the question at the same time!

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

Community Treasure Hunt

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

Start Hunting!

Translated by