How to find vector in array of vectors with the highest value of one component?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Michael Boyte
am 18 Apr. 2023
Kommentiert: Michael Boyte
am 19 Apr. 2023
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?
0 Kommentare
Akzeptierte Antwort
Matt J
am 18 Apr. 2023
Bearbeitet: Matt J
am 18 Apr. 2023
If I assume that p is an Nx4 array, then,
[~,row]=max(p(:,2));
result=p(row,1:3)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!