This solution is outdated. To rescore this solution, sign in.
-
2 Comments
Zunaed Kibria
on 16 Dec 2018
function B = swap_ends(A)
B = A(:,[end , 2:end-1 , 1]);
end
why its not working ??
Rahil Modi
on 14 Dec 2020
@Zunaed It doesn't work because it fails the 4th test case of A = [1]. I used that same code in the MATLAB software and it outputs B = [1 1] instead of B = [1] since you're printing out the last and first element of the matrix. You only should be printing [1] not [1 1]
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!