how I can make the matrix?

조회 수: 1 (최근 30일)
Akash Pal
Akash Pal 2021년 8월 26일
답변: the cyclist 2021년 8월 26일
  댓글 수: 1
Star Strider
Star Strider 2021년 8월 26일
I see no consistent relationship that could be coded as any sort of ‘rule’ as to what rows of 'A’ become ‘B’.
.

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

답변 (1개)

the cyclist
the cyclist 2021년 8월 26일
I think this does what you want. (It produces the correct output for your example.)
If not, I hope you can understand and adjust the logic.
A = [2 10 ;
2.5 8.9;
2.5 9 ;
2.65 9 ;
3 7 ;
3 8 ;
4 7.5;
4.5 4.9];
B = A;
idx = 2;
while idx < size(B,1)
if B(idx,1) >= B(idx-1,1) && B(idx-1,2) > B(idx,2)
idx = idx+1;
else
B(idx,:) = [];
end
end
B
B = 4×2
2.0000 10.0000 2.5000 8.9000 3.0000 7.0000 4.5000 4.9000

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by