Swap between columns - MATLAB Cody - MATLAB Central

Problem 59626. Swap between columns

Difficulty:Rate
The idea is to swap between second and second last column
Ex = [1 2 3 4 5;
1 2 3 4 5;
1 2 3 4 5;
1 2 3 4 5;
1 2 3 4 5];
will be:
Ex = [1 4 3 2 5;
1 4 3 2 5;
1 4 3 2 5;
1 4 3 2 5;
1 4 3 2 5];
If you like the problem, please like it :)

Solution Stats

77.84% Correct | 22.16% Incorrect
Last Solution submitted on Jun 12, 2025

Problem Comments

Solution Comments

Show comments
Why should you share code?
In a discussion on LInkedin about my recent blog post, Do these...
3
3

Problem Recent Solvers126

Suggested Problems

More from this Author9

Problem Tags

Community Treasure Hunt

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

Start Hunting!