필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
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?

채택된 답변

Matt J
Matt J 2023년 4월 18일
편집: Matt J 2023년 4월 18일
If I assume that p is an Nx4 array, then,
[~,row]=max(p(:,2));
result=p(row,1:3)
  댓글 수: 3
Torsten
Torsten 2023년 4월 19일
편집: Torsten 2023년 4월 19일
Apply fliplr or flipud to the vector and use max after this operation.
Or use the solution described here:

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by