Code covered by the BSD License  

Highlights from
LATSQ

5.0

5.0 | 2 ratings Rate this file 6 Downloads (last 30 days) File Size: 1.86 KB File ID: #12315

LATSQ

by Jos (10584)

 

18 Sep 2006 (Updated 03 Feb 2009)

(randomized) Latin Square

| Watch this File

File Information
Description

M = LATSQ(N) creates a latin square of size N-by-N containing the numbers 1 to N. N should be a positive integer. M is also known as the (backward shifted) circulant matrix of the vector 1:N.

[M, R] = LATSQ(N) also returns a randomized latin square in R.
 
A latin square of size N is a N-by-N matrix filled with N different numbers in such a way that each number occurs exactly once in each row and exactly once in each column. They have applications in the design of experiments.
More information: http://en.wikipedia.org/wiki/Latin_square

Example:
[M,R] = latsq(4) % ->
 % M is unrandomized
 % 1 2 3 4
 % 2 3 4 1
 % 3 4 1 2
 % 4 1 2 3
 % R is randomized
 % 2 3 1 4
 % 3 4 2 1
 % 4 1 3 2
 % 1 2 4 3
 
Note that "sort(ballatsq(N),1-2)" will return 1:N in each column-row.

See also MAGIC, GALLERY,
     BALLATSQ, CIRCULANT, SLM (File Exchange)

Latest version: 1.4 (feb 2009)

Acknowledgements
This submission has inspired the following:
latin cube
MATLAB release MATLAB 6.5 (R13)
Other requirements should work on most matlab releases
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
12 Aug 2007 Miguel Nacenta  
14 Jul 2010 W. Owen Brimijoin  
Please login to add a comment or rating.
Updates
19 Sep 2006

fixed minor spelling errors

20 Sep 2006

fixed error in randomization

03 Feb 2009

updated hellp

Tag Activity for this File
Tag Applied By Date/Time
statistics Jos (10584) 22 Oct 2008 08:39:56
probability Jos (10584) 22 Oct 2008 08:39:56
latin square randomize experiment Jos (10584) 22 Oct 2008 08:39:56

Contact us at files@mathworks.com