From: Dustin on
I have a section of code I would like to speed up if any gurus out there can help me. I have a large dataset that I am bringing in with a column of timestamps. Thanks to the users on this forum i found out that i needed to adjust the fromat to keep the required precision to do some pretty simple filtering and calculations.

Now that everything works as expected is there anyway to speed up datenum to reduce time on the profiler results below. Keeping in mind i dont have any control over the incoming format.


0.00 346 data.timeStamp = data.raw(:,1); %map
0.00 347 shortIndex = cellfun('length', data.timeStamp) < 11; %catch small stamps
0.02 348 data.timeStamp(shortIndex) = strcat(data.timeStamp(shortIndex), {' 00:00:00 AM'}); %adjust format. necessary to keep precision.
2.52 349 data.timeSerial = datenum(data.timeStamp); %convert to serial
From: Walter Roberson on
Dustin wrote:
> I have a section of code I would like to speed up if any gurus out there
> can help me. I have a large dataset that I am bringing in with a column
> of timestamps. Thanks to the users on this forum i found out that i
> needed to adjust the fromat to keep the required precision to do some
> pretty simple filtering and calculations.
> Now that everything works as expected is there anyway to speed up
> datenum to reduce time on the profiler results below. Keeping in mind i
> dont have any control over the incoming format.
>
>
> 0.00 346 data.timeStamp = data.raw(:,1); %map 0.00 347 shortIndex
> = cellfun('length', data.timeStamp) < 11; %catch small stamps
> 0.02 348 data.timeStamp(shortIndex) =
> strcat(data.timeStamp(shortIndex), {' 00:00:00 AM'}); %adjust format.
> necessary to keep precision. 2.52 349 data.timeSerial =
> datenum(data.timeStamp); %convert to serial

You _might_ be able to get a minor speedup if you pass in
char(data.timeStamp)
to datenum instead of passing in a cell. I'm just thinking that would reduce
the number of string length checks that would have to be done.
From: us on
"Dustin " <dbrisset(a)gmail.com> wrote in message <i3siek$5lv$1(a)fred.mathworks.com>...
> I have a section of code I would like to speed up if any gurus out there can help me. I have a large dataset that I am bringing in with a column of timestamps. Thanks to the users on this forum i found out that i needed to adjust the fromat to keep the required precision to do some pretty simple filtering and calculations.
>
> Now that everything works as expected is there anyway to speed up datenum to reduce time on the profiler results below. Keeping in mind i dont have any control over the incoming format.
>
>
> 0.00 346 data.timeStamp = data.raw(:,1); %map
> 0.00 347 shortIndex = cellfun('length', data.timeStamp) < 11; %catch small stamps
> 0.02 348 data.timeStamp(shortIndex) = strcat(data.timeStamp(shortIndex), {' 00:00:00 AM'}); %adjust format. necessary to keep precision.
> 2.52 349 data.timeSerial = datenum(data.timeStamp); %convert to serial

a hint:
- look at this recent, great FEX submission by senior CSSMer jan simon...

http://www.mathworks.com/matlabcentral/fileexchange/28093-datestr2num

us
From: Steven_Lord on


"Dustin " <dbrisset(a)gmail.com> wrote in message
news:i3siek$5lv$1(a)fred.mathworks.com...
> I have a section of code I would like to speed up if any gurus out there
> can help me. I have a large dataset that I am bringing in with a column of
> timestamps. Thanks to the users on this forum i found out that i needed to
> adjust the fromat to keep the required precision to do some pretty simple
> filtering and calculations.
> Now that everything works as expected is there anyway to speed up datenum
> to reduce time on the profiler results below. Keeping in mind i dont have
> any control over the incoming format.
>
>
> 0.00 346 data.timeStamp = data.raw(:,1); %map 0.00 347 shortIndex =
> cellfun('length', data.timeStamp) < 11; %catch small stamps
> 0.02 348 data.timeStamp(shortIndex) = strcat(data.timeStamp(shortIndex),
> {' 00:00:00 AM'}); %adjust format. necessary to keep precision. 2.52
> 349 data.timeSerial = datenum(data.timeStamp); %convert to serial

Look at the Note in the reference page for DATENUM:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/datenum.html

Have you tried specifying the date format in your call to DATENUM, so that
DATENUM doesn't have to try to deduce it?

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

From: Dustin on
"Steven_Lord" <slord(a)mathworks.com> wrote in message <i3uo6u$lfi$1(a)fred.mathworks.com>...
>
>
> "Dustin " <dbrisset(a)gmail.com> wrote in message
> news:i3siek$5lv$1(a)fred.mathworks.com...
> > I have a section of code I would like to speed up if any gurus out there
> > can help me. I have a large dataset that I am bringing in with a column of
> > timestamps. Thanks to the users on this forum i found out that i needed to
> > adjust the fromat to keep the required precision to do some pretty simple
> > filtering and calculations.
> > Now that everything works as expected is there anyway to speed up datenum
> > to reduce time on the profiler results below. Keeping in mind i dont have
> > any control over the incoming format.
> >
> >
> > 0.00 346 data.timeStamp = data.raw(:,1); %map 0.00 347 shortIndex =
> > cellfun('length', data.timeStamp) < 11; %catch small stamps
> > 0.02 348 data.timeStamp(shortIndex) = strcat(data.timeStamp(shortIndex),
> > {' 00:00:00 AM'}); %adjust format. necessary to keep precision. 2.52
> > 349 data.timeSerial = datenum(data.timeStamp); %convert to serial
>
> Look at the Note in the reference page for DATENUM:
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/datenum.html
>
> Have you tried specifying the date format in your call to DATENUM, so that
> DATENUM doesn't have to try to deduce it?
>
> --
> Steve Lord
> slord(a)mathworks.com
> comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

thanks this helps the most