ABSTRACT

Computers can carry out different operations depending on the conditions in effect at the time. Calculators cannot do that, regardless of whether they are electronic or mechanical (as in an abacus). Calculators cannot deal with contingencies. This chapter is about contingencies in MATLAB. Understanding how to work with contingencies in the MATLAB programming environment will help to do much, much more with a computer than one can with an abacus and that one can do with MATLAB, poorly understood. The chapter shows how to a create a Latin square for multiple groups. The aim is to create a more general program to generate Latin squares for several groups and several subjects per group. A further aim is to add a constraint: all the subjects within a group must have distinct orders. The program produces an output matrix, called perm_order, whose columns are group number, subject number, first condition tested, second condition tested, all the way up to sixth condition tested.