Date Conversion Not Working Again
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi, I'm sorry for posting a similar problem again - I keep encountering it and I'm not sure what i'm doing wrong. I simply want to upload a series of dates into MatLab but every time it goes through datnum to datestr the dates that come out are completely different to those I put in. I thought the problem last time might have been using excel to upload the data so now I'm only using text files. I have attached the bit of code and my input file - the first three dates I get back in the date string are - 04-Apr-2017, 06-Jul-2018, 06-Oct-2018. Any help or advice would be very much appreciated.
% Load OB Data
OB20172 = readtable('OB20176.txt');
% Create GS Time
datetime.setDefaultFormats('default','dd-MM-yyyy');
t1 = datetime(2017,04,1,0,0,0);
t2 = datetime(2017,10,31,8,0,0);
GS2017 = t1:t2;
%Convert OB Date
OBDates = OB20172;
OB2017 = table2array(OBDates);
OBDateNumbers = datenum(OB2017);
DateString = datestr(OBDateNumbers);
답변 (0개)
참고 항목
카테고리
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!