MATLAB: Can I perform circular rotation of a vector using Simulink 7.2 (R2008b)

circshiftsimulink

I would like to use a built-in Simulink block to rotate a vector in a circular fashion by a specified amount. Specifically, the block should accept a vector input and allow me to specify the amount of rotation as a dialog parameter. For example, if I input the vector [5 6 7 8] and specify the amount of rotation as two, the block outputs the vector [7 8 5 6].

Best Answer

The ability to perform an arbitrary circular rotation of vectors is supported in Simulink by use of CIRCSHIFT command within Embedded MATLAB block from Simulink 7.2 (R2008b) onwards .
Please see the attached model 'vec_rot_9bpre.mdl' below to see how the functionality can be achieved.
If you have a version previous to R2008b, you may choose to write your own S-Function, or MATLAB Function block to implement an algorithm that rotates vectors by a specified amount. Or create a masked subsystem whose mask parameters control the dialog parameters of an underlying Selector block.