Swapping Blocks in a Matrix
4 次查看(过去 30 天)
显示 更早的评论
Hello. I'm trying to swap the first two numbers of the first and second rows of this test matrix with the last two numbers of the second and third rows. Is there any way to swap these numbers in a matrix that's not one row and/or not on the same row?
x = [1 2 3 4 5;
6 7 8 9 10;
11 12 13 14 15]
The result should be:
x = [9 10 3 4 5;
14 15 8 1 2;
11 12 13 6 7]
0 个评论
采纳的回答
更多回答(1 个)
Bruno Luong
2018-9-12
编辑:Bruno Luong
2018-9-12
[x(1:2,1:2) x(2:3,4:5)] = deal(x(2:3,4:5),x(1:2,1:2))
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!