Problem 19. Swap the first and last columns
Flip the outermost columns of matrix A, so that the first column becomes the last and the last column becomes the first. All other columns should be left intact. Return the result in matrix B.
If the input has one column, the output should be identical to the input.
Example:
Input A = [ 12 4 7
5 1 4 ];
Output B is [ 7 4 12
4 1 5 ];
Solution Stats
Problem Comments
-
18 Comments
Show
15 older comments
Saicharan
on 11 Jul 2022
Good problem.
Long Runjia Yu
on 10 Feb 2024
very nice
VBBV
on 5 Apr 2024
Good one
Solution Comments
Show commentsGroup

Practice with Functions
- 14 Problems
- 3 Finishers
- Get the length of a given vector
- Whether the input is vector?
- Flip the vector from right to left
- Create a vector
- Doubling elements in a vector
- Column Removal
- Swap the first and last columns
- Reverse the vector
- Length of the hypotenuse
- Return the first and last characters of a character array
- Roll the Dice!
- Triangle Numbers
- Sum all integers from 1 to 2^n
- Dog Statistics
Problem Recent Solvers21194
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!