Given a matrix and an index, perform matrix transposition as follows -
Replace non-corner value of ith ring from outside, with the adjacent values of the next ring.
x = [1 2 3 4
5 6 7 8
1 2 3 4];
i = 1; %operate on outermost ring of matrix
y = [1 6 7 4
6 6 7 7
1 6 7 4];
x = [4 1 4 6 0 5
1 4 9 6 9 9
0 2 8 4 9 1
5 8 4 0 6 5
9 2 7 3 6 2
8 0 6 3 2 7
3 1 9 6 2 2];
i = 2; %operate on second ring of matrix
y = [4 1 4 6 0 5
1 4 8 4 9 9
0 8 8 4 4 1
5 4 4 0 0 5
9 7 7 3 3 2
8 0 7 3 2 7
3 1 9 6 2 2];
x = [6 5 1 0 7 4 2
3 6 9 4 6 9 5
7 9 3 3 6 3 3
2 4 5 2 3 3 5
7 4 0 1 4 5 1
7 8 5 9 5 1 4
9 2 5 6 7 6 8];
i = 3; %operate on third ring of matrix
y = [6 5 1 0 7 4 2
3 6 9 4 6 9 5
7 9 3 2 6 3 3
2 4 2 2 2 3 5
7 4 0 2 4 5 1
7 8 5 9 5 1 4
9 2 5 6 7 6 8];

Solution Stats

22 Solutions

13 Solvers

Last Solution submitted on Apr 17, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers13

Suggested Problems

More from this Author44

Community Treasure Hunt

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

Start Hunting!