Code covered by the BSD License  

Highlights from
SHAKE

4.0

4.0 | 3 ratings Rate this file 8 Downloads (last 30 days) File Size: 2.11 KB File ID: #10067

SHAKE

by Jos (10584)

 

20 Feb 2006 (Updated 14 May 2008)

Randomize a matrix along one dimension (ver 4 .1 may 2008)

| Watch this File

File Information
Description

SHAKE - Randomize a matrix along a specific dimension

Y = SHAKE(X) randomizes the order of the elements in each column of the 2D matrix. For N-D matrices it randomizes along the first dimension.
 
SHAKE(X,DIM) randomizes along the dimension DIM.

[Y, I, J] = SHAKE(...) return index matrices I and J so that Y = X(I) and X = Y(J).
 
Example:
  A = [1 2 3 ; 4 5 6 ; 7 8 9 ; 10 11 12] ; % see <slm> on the FEX ...
  Dim = 2 ;
  [B, ID] = shake(A,Dim) % ->, e.g.
  % 3 2 1
  % 6 4 5
  % 7 8 9
  % 11 10 12%
 
See also RAND, SORT, RANDPERM
and RANDSWAP on the File Exchange

Latest version: 4.1 (may 2008)

Acknowledgements
This submission has inspired the following:
RANDSWAP, Permute a grouped vector
MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
21 Feb 2006 John D'Errico

Its not shaky at all. Certainly not its documentation, which is as clear as even I could ask for.

01 Apr 2006 Peter He

Tests show that the quality of randomization is not good. Cannot be trusted in serious simulations.

06 May 2006 Jos vdG

Which tests? Note that <shake> simply uses the built-in matlab <rand> function ...

01 Jun 2006 Gregory Anderson

Simple? Yes, but I couldn't figure out how to do it on my own, and it does exactly what it's supposed to do, so thanks, Jos.

12 Oct 2006 Jos (author)

New version: 3.0 (oct 2006)

Please login to add a comment or rating.
Updates
24 Aug 2006

SHAKE can now randomize along any dimension.

12 Oct 2006

new algorithm
return 2 indices

13 Dec 2006

dec 2006 - fixed major bug in functionality

14 May 2008

fixed error for scalar inputs

Tag Activity for this File
Tag Applied By Date/Time
matrices Jos (10584) 22 Oct 2008 08:16:23
sort Jos (10584) 24 Oct 2008 15:41:03
randomize Jos (10584) 24 Oct 2008 15:41:03
matrix Jos (10584) 24 Oct 2008 15:41:03
rand Jos (10584) 24 Oct 2008 15:41:03
shake Jos (10584) 24 Oct 2008 15:41:03
shuffle Jos (10584) 24 Oct 2008 15:41:03
permute Jos (10584) 24 Oct 2008 15:41:03
order Jos (10584) 24 Oct 2008 15:41:03

Contact us at files@mathworks.com