MATLAB: How to move an element from an array

array

I have an array and i want to to move the element a which located in x line, by one position to the right without change the left part

Best Answer

Hello Georgios,
I'm not sure what the absolute best way to do this for your particular application, but here is one way you could do it.
A = [1 2 3 4 0 0 0 ; 5 3 2 1 0 0 0];
Aorig = A;
A(2,4:5) = Aorig(2,3:4);
A(2,3) = Aorig(2,5);
Or if you'd rather one-line it:
A(2,3:5) = A(2,[5 3 4]);
I'll let you work out a more general function though, depending on what you know, and what you'll need to adapt for as an input.
-Cam