
160 Accelerating MATLAB
®
Performance
% Using the internal dtstr2dtvecmx (25x faster)
dateVecs = dtstr2dtvecmx(timestamps,'yyyy-MM-dd HH:mm:ss');
⇨ Elapsed time is 0.008838 seconds.
The datenum function uses another internal function that we can utilize in a certain sit-
uation. Specically, if our input uses a 6-element numeric date-vector format,* then using
datenummx will be more efcient:
411
dateVecs = clock;
for idx=1:1000, dateNums = datenum(dateVecs); end
⇨ Elapsed time is 0.015782 seconds.
for idx=1:1000, dateNums = datenummx(dateVecs); end
⇨ Elapsed time is 0.001152 seconds.
datenummx used to be a separate mex le whose source ...