how to circularly shift the entire elements of a matrix

1 view (last 30 days)
i need to shift the elements by one position if the input is
a=[1 2 3;4 5 6;7 8 9]
the output i needed is
b=[9 1 2;3 4 5;6 7 8]
pls send me the code

Answers (1)

Stephen23
Stephen23 on 21 Mar 2018
>> b = a.';
>> b(:) = b([end,1:end-1]);
>> c = b.'
c =
9 1 2
3 4 5
6 7 8

Categories

Find more on Spline Postprocessing in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!