Scilab Home Page | Wiki | Bug Tracker | Forge | Mailing List Archives | Scilab Online Help | ATOMS
File : Details
Login with GitLab

circular shifts cshift()

Circularly shifts components of a vector, matrix, hypermatrix of any data type along its dimensions
(1706 downloads for this version - 4508 downloads for all versions)
Details
Version
1.0
A more recent valid version with binaries for Scilab exists: 2.0
Author
Samuel Gougeon
Maintainer
Samuel Gougeon
Category
License
Supported Scilab Version
5.0
Creation Date
May 15, 2011
Description
            cshift(M,d): Circularly shifts rows, columns, pages,... of a vector, matrix or
hypermatrix M. 

* Any subset of M's dimensions may be shifted through a single call to
cshift().
* M can be of any unmixed data type
* cshift() cannot be used with cells.

To get help and examples, type: -->cshift  // with no argument

EXAMPLES:

-->M = grand(3,4,"uin",0,9)
 M  =
    2.    4.    8.    0.  
    1.    1.    5.    1.  
    0.    9.    2.    8.  

-->cshift(M,1) // Shifts rows down by 1
 ans  =
    0.    9.    2.    8.  
    2.    4.    8.    0.  
    1.    1.    5.    1.   

-->cshift(M,-1) // Shifts rows up by 1
 ans  =
    1.    1.    5.    1.  
    0.    9.    2.    8.  
    2.    4.    8.    0.  
 
-->cshift(M,[0 -1]) // Shifts columns left by 1
 ans  =
    4.    8.    0.    2.  
    1.    5.    1.    1.  
    9.    2.    8.    0.  

-->cshift(M,[0 2]) // Shifts columns right by 2
 ans  =
 
    8.    0.    2.    4.  
    5.    1.    1.    1.  
    2.    8.    0.    9.  

-->cshift(M,[1 2]) // Shifts rows down by 1, and columns right by 2
 ans  = 
    2.    8.    0.    9.  
    8.    0.    2.    4.  
    5.    1.    1.    1.  
            
Files (1)
[1.02 kB]
Miscellaneous file
Macro
News (0)
Comments (1)     Leave a comment 
Comment from David Chèze -- October 8, 2014, 06:06:40 PM    
Dear Samuel,
it's fine, did you consider to integrate this useful feature within scilab core 
distribution?

Thanks,

David
Leave a comment
You must register and log in before leaving a comment.
Login with GitLab
Email notifications
Send me email when this toolbox has changes, new files or a new release.
You must register and log in before setting up notifications.