how I can make the matrix?
2 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/722074/image.png)
1 个评论
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
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!