Code covered by the BSD License  

Highlights from
latins

1.0

1.0 | 1 rating Rate this file 0 Downloads (last 30 days) File Size: 1.77 KB File ID: #19045

latins

by Jon Farrimond

 

04 Mar 2008 (Updated 04 Mar 2008)

Produces a latin square of required dimensions

| Watch this File

File Information
Description

User enters latins(row,col) where row is the number of required rows and col the required columns. A CSV file with an ISO8601 timestamp is produced and the latin square of randomised values is displayed to the screen.

The latin square doesn't have to be square though.

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
05 Mar 2008 Jos x@y.z

non square latin square ??

Why not simply output the result as a matrix and let the user store the matrix, if they want to? And what are rowout, colout doing?

Finally, take a look at my vectorized implementation of latin squares:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=12315&objectType=FILE

or balanced latin squares:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=9996&objectType=FILE

05 Mar 2008 John D'Errico

Jos was kind in not providing a rating. He probably felt that since he had a code that does the same thing, it would be a conflict of interest.

This submission has poor documentation. Its poor code in general.

The author has an interesting coding style, that I might worry about. I'm intrigued by the lines of code that are just:

colflag + 1;

and

rowflag + 1;

Nothing is assigned. The author merely adds 1 to rowflag and colflag, then dumps the result into the bit bucket. Is this a bug? Who knows? But I might not trust this code.

There is no H1 line. So next year when you want to find this code, lookfor will not help you.

A kludge of an interface too. It writes out a csv file, of its own choice of name and placement on your file system. If you don't have write access in that directory, tough luck. Or perhaps it might choose to overwrite the last file you just created. Ridiculous? Yes. Why not just return the latin square as an argument? This makes far more sense than returning two parameters that can not be useful.

The code resets the rand state on you, in case that matters to anyone.

As for latin rectangles, I'm waiting for a code that produces a latin triangle.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
statistics Jon Farrimond 22 Oct 2008 09:51:36
probability Jon Farrimond 22 Oct 2008 09:51:36
latin square Jon Farrimond 22 Oct 2008 09:51:36
row Jon Farrimond 22 Oct 2008 09:51:36
columns Jon Farrimond 22 Oct 2008 09:51:36
time stamp Jon Farrimond 22 Oct 2008 09:51:36

Contact us at files@mathworks.com