How to make datenum more efficient for large arrays?
조회 수: 3 (최근 30일)
이전 댓글 표시
I am using textscan() to create an matrix that is 3,081,680 rows long. The very first column, A{1}, is the timestamp column, and it's elements look like this:
"2011-01-23 18:38:30"
I have tried using datenum() to convert this, but it is either taking too long or not working at all (longer than ten minutes). Is there a way I can make this more efficient?
Thanks!
댓글 수: 0
채택된 답변
Cedric
2013년 10월 29일
편집: Cedric
2013년 10월 29일
What is the purpose ultimately? Do you need an accurate time stamp which accounts for the date and time? If you were computing daily averages for 2011 only, for example, we could find a way to generate month/day IDs probably faster than DATENUM.
Otherwise, there are FEX contributions, e.g. this one by Jan Simon: http://www.mathworks.com/matlabcentral/fileexchange/28093-datestr2num
as well as a few relevant threads, among which: http://undocumentedmatlab.com/blog/datenum-performance/
댓글 수: 5
Cedric
2013년 10월 30일
You're welcome. Let me know if you go for an ACCUMARRAY approach for binning and need help with that.
추가 답변 (1개)
Kelly Kearney
2013년 10월 29일
Are you specifying the date format? Particularly for large arrays,
datenum(A{1}, 'yyyy-mm-dd HH:MM:SS')
will be much faster than
datenum(A{1})
댓글 수: 3
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!