matlab - How to Shift an array circularly on VBA -


I have an array (1,2,3) and I want to make a circular change to get the example (3,1,2) or (2,3,1) in Matlab I know how to use the following code:

  y = circuschift (A, K) < / Code> 

Can you help me with this work? I appreciate any sample code ...

code:

  private function RotateArrayRight (ByVal ArrayToRotate object (), ByVal iPlacesToRotate (as) as the object as a whole) object as dim objNewArray () in as dim iOldArrayPos, iNewArrayPos integer dim iArrayLength The integer check that ArrayToRotate has not been started to process the array is' Check that the number of place is rotated by the rotation More than that - the function of running the function with 'value' which is less than zero can cause problems, possibly due to the accident causing the iPlacesToRotate & gt; 0 then the length of the array to rotate ', we are using it a few times, so it' iArrayLength = ArrayToRotate.Length 'loaded into a local variable in the beginning of' Array ArrayLength -1 0 'it ArrayLength elements will include ReDim objNewArray (iArrayLength - 1) 'it indexes any additional full rotation array of modern operator will remove through an integer division operation iPlacesToRotate = iPlacesToRotate Mod iArrayLength of trhe latest return' array status Initialise IOldArrayPos = iPlacesTo Rotate iNewArrayPos = 0 'Copy the next items from the array's first start in the old array Aiplestorotet' and copy the beginning of the new array. While iOldArrayPos & lt; iArrayLength objNewArray (iNewArrayPos) = ArrayToRotate (iOldArrayPos) iOldArrayPos + = 1 iNewArrayPos + = 1 end while iOldArrayPos = 0 'from the copy of the end began in array "While iOldArrayPos or & lt new Array; Aipls Turatet Ojhenaarere (iNewArrayPos) = Arretoratet (iOldArrayPos) iOldArrayPos + = 1 iNewArrayPos + = 1 to the new logic OUTOfRangeException ( " 'location' value to be transferred must be greater than zero ending. ') End if other throw new NullReferenceException ( "rotate a null array.") that return objNewArray finale  

you can use the function as an example: {4, 9, 2, 1} dim iArray2 (), iArray3 () as object iArray2 = RotateArrayRight (iInputArray, 2) 'the two positions iArray3 = RotateArrayRight (iInputArray, 98,977) shifted to the 98,977 positions Shift

:

  iOldArrayPos + = 1 = & gt; IOldArrayPos = iOldArrayPos + 1 termination = & gt; Wend Throw = & gt; MsgBox  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -