Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help
next up previous contents
Next: Calling Fortran or C Up: Miscellaneous Previous: Program-generated names and commands

Vectorising

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). See the Matlab vectorisation tricks page for details.



© Cambridge University Engineering Dept
Information provided by Tim Love
2006-07-24