From: Steven Lord on

"Chris " <ridered300tr(a)hotmail.com> wrote in message
news:hkhl3o$53j$1(a)fred.mathworks.com...
>> This piece of code has no sense until you won't specify what do you mean
>> by 'array'.
>>
>> Oleg
>
> array is just a mxn matrix of numbers. This function rotates the numbers
> down the first column, up the second column, down the third column, and so
> on. When numbers reach the top or bottom of the column they jump to the
> next column. The last number in the matrix jumps to the first number. I
> want this function to repeat x times... The code works but only 1 time.

I _think_ I understand what you're trying to do, but to confirm ... what do
you want this code to do on some small examples? What would you want A, B,
C, and D to be after executing the following code?

M = [1 2 3;4 5 6];
N = [7 8;9 10; 11 12];
A = twist(M, 2)
B = twist(M, 3)
C = twist(N, 2)
D = twist(N, 4)

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ