
94 Accelerating MATLAB
®
Performance
For example, it turns out that datenum('2013-02-15') is an order of magnitude slower
than datenum('2013-02-15','yyyy-mm-dd'), because the former needs to perform all
sorts of checks and computations to determine the date format. By specifying the extra
(optional) input parameter telling the function the data string format, we shave away these
run-time computations.*
Similarly, if our date strings are properly formatted, we could use the internal dtstr2dt-
nummx directly, rather than the datenum function, bypassing all the latter’s sanity and
formatting checks and improving performance even further. Jan Simon ...