[Help me, please] How to find 3 point maximum matrix in matlab ?

조회 수: 1 (최근 30일)
Lee Bruce
Lee Bruce 2017년 6월 7일
댓글: Lee Bruce 2017년 6월 7일
A=[7 5 3 9 2 4;1 2 4 6 3 3]' how to result 3 point max:
A= 7 1
5 2
3 4
9 6
2 3
4 3
X= 9 7 5
Y= 6 1 2
Thank you for watching, i hope an answers.
My english is bad.
  댓글 수: 1
Stephen23
Stephen23 2017년 6월 7일
편집: Stephen23 2017년 6월 7일
See my answer for a simpler solution than the accepted answer.

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

채택된 답변

H ZETT M
H ZETT M 2017년 6월 7일
I am not sure if this is what you wanted, but I managed to recreate what the code should be doing to get your results.
A=[7 5 3 9 2 4;1 2 4 6 3 3]'
[B,I]=sort(A(:,1),'descend')
X=(B(1:3))'
Y=A(I(1:3),2)'

추가 답변 (1개)

Stephen23
Stephen23 2017년 6월 7일
>> Z = sortrows(A,-1);
>> X = Z(1:3,1)
X =
9
7
5
>> Y = Z(1:3,2)
Y =
6
1
2

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by