# Indexing in a vector

7 visualizaciones (últimos 30 días)
MOHAMED ABDULAZIM el 16 de Ag. de 2020
Comentada: MOHAMED ABDULAZIM el 16 de Ag. de 2020
I am trying to extract maximum value from a vector by max() function,however I need to know the index of this value in the vector in order to use this indexing in performing another operation by writing a script file.How to know the index of the element in the array?
##### 2 comentariosMostrar NingunoOcultar Ninguno
the cyclist el 16 de Ag. de 2020
You refer to your input as both a "vector" (one-dimensional) and an array (could be any dimension, but typically two).
Which is it?
MOHAMED ABDULAZIM el 16 de Ag. de 2020
a vector (one-dimensional)

Iniciar sesión para comentar.

the cyclist el 16 de Ag. de 2020
Please see my comment.
If your input is a vector (i.e. one-dimensional), then
[maxValue indexToMaxValue] = max(inputVector);
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Más respuestas (1)

Sara Boznik el 16 de Ag. de 2020
r=triu(r);
r;
w=min(r(r>0));
b=max(r(:));
[m,n]=find(r==w);
fprintf(id,'Minimum %.4f.\n',w);
for i=1:length(m)
fprintf(id,'Points %d in %d.\n',m(i),n(i));
end
[m,n]=find(r==b)
fprintf(id,'Maksimum %.4f.\n',b)
fprintf(id,'Points %d in %d.\n',m,n);
Here is part of my code where we searching the min and max.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

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

R2013a

### Community Treasure Hunt

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

Start Hunting!

Translated by