How to "restart" a matrix from an especific element

Hi everyone. I have a square matrix like this: [1,2,3;4,5,6;7,8,9]
How could I restart the sequence from an especific element? For example, I want to restart the sequence from 4, so the matrix will be: [1,2,3;4,1,2;3,4,5]
Thanks a lot!

 Réponse acceptée

restart_after := 4;
Matrix(restart_after+1:end) = Matrix(1:end-restart_after);

1 commentaire

Thanks. But that works when the matrix is ordered by columns. If the sequence is sorted by rows, like the example, don't.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by