Datetime conversion in numeric form (matrix)
조회 수: 30 (최근 30일)
이전 댓글 표시
So, I have been trying to convert date to a number and add it to the first column of a numeric matrix.
Unfortnatelly, I use the code below to create the matrix for a specific range of dates but the dates were imported as strings not numbers (see picture). i have no dea why this doesn't work. Any idea?
t1=datetime([2001 01 01 00 00 00]);
t2=datetime([2017 12 31 23 00 00]);
t=[t1:1/24:t2];
time = datetime(t); %this is where the conversion should have happened
time=time';
Firstly, I set the starting and finishing point and then, I choose to insert data by the hour.
After that I try but fail to do the numeric conversion.
Any help is appreciated!
댓글 수: 0
채택된 답변
Star Strider
2019년 7월 7일
timeNr = datenum(time);
If you want to convert them into something else numeric, please be specific.
추가 답변 (1개)
Steven Lord
2019년 7월 7일
Rather than converting your datetime array into a number to combine it with a numeric array, consider creating a timetable array instead.
댓글 수: 2
참고 항목
카테고리
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!