File Exchange

image thumbnail

latsq(N)

version 2.0 (2.08 KB) by

Latin Square Matrix

6 Downloads

Updated

View License

latsq - Latin Square
M = latsq(N) creates a latin square of size N-by-N containing
the numbers 1 to N. N should be a positive integer.

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. The output M is also known as the (backward shifted)
circulant matrix of the vector 1:N.

Examples:
M = latsq(4) % ->
% 1 2 3 4
% 2 3 4 1
% 3 4 1 2
% 4 1 2 3

% latin square of categories
C = {'goat','cabbage','wolf'}
idx = latsq(numel(C))
M = C(idx)

% Randomized latin square
V = randperm(6)
M = V(latsq(numel(V)))

See also magic, gallery,
ballatsq, circulant, slm (file Exchange)

More information: http://en.wikipedia.org/wiki/Latin_square

Comments and Ratings (2)

Owen Brimijoin

Miguel Nacenta

Updates

2.0

added some additional help ; removed second output

1.1

updated hellp

fixed minor spelling errors

MATLAB Release
MATLAB 9.3 (R2017b)
Acknowledgements

Inspired: latin cube

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today