Counting floating point operations in MATLAB

Somebody asked how one may count the number of floating point operations in a MATLAB program.

Prior to version 6, one used to be able to do this with the command flops, but this command is no longer available with the newer versions of MATLAB.

flops is a relic from the LINPACK days of MATLAB (LINPACK has since been replaced by LAPACK). With the use of LAPACK in MATLAB, it will be more approrpiate to use tic and toc to count elapsed CPU time instead (cf. tic,toc).

If you're interested to know why flops is obsolete, you may wish to read the exchanges in NA digest regarding flops.

Nevertheless, if you feel that you really do need a command to count floating point operations in MATLAB, what you can do is to install Tom Minka's Lightspeed MATLAB toolbox and use the flops counting operations therein.