"Restart" elements of a matrix

1 view (last 30 days)
Facundo Beer
Facundo Beer on 1 Jul 2015
Answered: Matt J on 1 Jul 2015
Hi! I have a couple of matrix (all squares and sorted by rows) like this:
A=[1 2 3; 4 5 6; 7 8 9]
And I need to, from any specific element, restart the sequence. For example:
A=[1 2 3; 1 2 3; 4 5 6]
Any ideas? Thanks a lot!

Answers (1)

Matt J
Matt J on 1 Jul 2015
restart=4; % your example
N=numel(A);
B=A.';
B(restart:N)=B(1:N-restart+1);
result=B.';

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!