Borrar filtros
Borrar filtros

How to find vector in array of vectors with the highest value of one component?

1 visualización (últimos 30 días)
I feel like there's an easy solution to this that I'm missing. I have an array of points, p(x,y,z,i), in which the first three components, x, y, and z, are a point in 3d space and the last component, i, is the number assigned to that point. I want to search through the array and find the vector with the highest y-value. How can I do this?

Respuesta aceptada

Matt J
Matt J el 18 de Abr. de 2023
Editada: Matt J el 18 de Abr. de 2023
If I assume that p is an Nx4 array, then,
[~,row]=max(p(:,2));
result=p(row,1:3)
  3 comentarios
Torsten
Torsten el 19 de Abr. de 2023
Editada: Torsten el 19 de Abr. de 2023
Apply fliplr or flipud to the vector and use max after this operation.
Or use the solution described here:

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by