However, fminsearch(), fgoalattain(), fmincon(). fminunc(), fseminf(), lsqcurvefit(), lsqnonlin(), fsolve() and fzero() donot accept expressing the function in terms of matrices.
The timer function is exactly what you want. If it seems too complicated, start at the beginning of the MATLAB documentation and by the time you get to timers, it will make sense.
Best Answer