for loops are slow and can often be eliminated, though the
resulting code may be less readable. For example, to replace all values <-1 by -1 and all values >1 by 1 in
a matrix A you can just do A = min(max(M, -1),1).
Matlab vectorisation tricks
page for details.