This solution is outdated. To rescore this solution, sign in.
-
3 Comments
kifah alzoubi
on 29 Dec 2016
function [B] = swap_ends(A)
%SWAP_ENDS Solution 19: Swap the first and last columns
if length(A)>1
B=cat(2,A(:,length(A)),A(:,2:length(A)-1),A(:,1));
else
B=A;
end
end
zefeng chen
on 17 Jun 2017
nice
Nico Noordam
on 3 Jan 2020
length not correct, use size(A,2)
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!