Code covered by the BSD License  

Highlights from
Shuffle Numbers

Be the first to rate this file! 4 Downloads (last 30 days) File Size: 1.24 KB File ID: #34868

Shuffle Numbers

by Aamir Alaud-din

 

01 Feb 2012

Shuffles numbers in a given matrix or vector

| Watch this File

File Information
Description

Shuffles numbers in a given m-by-n matrix or 1-by-n vector. The output will have the same number of rows and columns as the input matrix or vector but with shuffled numbers.

Required Products MATLAB
MATLAB release MATLAB 7.6 (R2008a)
Tags for This File  
Everyone's Tags
finance, mathematics, rand, randomization, shuffle, statistics
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
21 Nov 2012 Jan Simon

The function "vec2mat" is unknown.

02 Feb 2012 Jos (10584)

This functionality has been around on the File Exchange for years. For instance, you might take a look at my RANDSWAP function
http://www.mathworks.nl/matlabcentral/fileexchange/12621-randswap

or RANDMAT by Peter Bodin
http://www.mathworks.nl/matlabcentral/fileexchange/7203-randmat

Here is the rather trivial one-liner for shuffling any array X (numbers, ND, cell, string, whatever):

X(randperm(numel(X)) = X ;

which maintains everything, except the order!

Your help section is pretty good; I'd suggest you try to follow ML standards, e.g., by creatin a proper H1 line, and example, and a See Also section (take a look at the help of any of the main ML functions)

Contact us