Finding maximum between every two rows of a matrix
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I have a matrix that I am trying to break up based on maximums. I will explain this with a simplified example. So I have a matrix as follows:
A=[1 2 3;6 7 8;4 5 6;1 2 3;4 5 6;1 2 3];
I am trying to create a new matrix based off of this matrix as follows. I want to include the first and last row UN-changed in the new matrix, then find the maximum between every two rows of column 2 and return that row to the new matrix. So the new matrix would be
newA=[1 2 3;6 7 8;4 5 6;1 2 3]
So the first row in newA is [1 2 3] because it is left unchanged. Row 2 is [6 7 8] because between row 2 and 3, row 2 has the larger value in column 2. Row 3 is [4 5 6] because between row 4 and 5, row 5 has the larger value in column 2. Row 4 is [1 2 3] because it is left unchanged.
Any help would be great. Thanks!
1 个评论
Walter Roberson
2013-11-17
编辑:Walter Roberson
2013-11-17
This looks like it should be similar to your earlier question http://www.mathworks.co.uk/matlabcentral/answers/106342-finding-maximums-in-matrix-columns . I don't see the difference at the moment ?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!