필터 지우기
필터 지우기

How can I use: DateString/datevac for a long year dataset? Dates from 01/01/1988 to 05/03/2005?

조회 수: 3 (최근 30일)
How can I use: DateString = '01/01/1988'; formatIn = 'dd/mm/yyyy'; datevec(DateString,formatIn)
to convert a long data column Date = G(:,1); Dates are in dd/mm/yyyy: from 01/01/1988 to 05/03/2005 and I need to change them to yyyy mm dd to have them the same as other data I am using in a script?
It currently converts only 01/01/1988, to:
ans =
1988 1 1 0 0 0
I tried:
DateString = '01/01/1988:05/03/2005'; formatIn = 'dd/mm/yyyy'; datevec(DateString,formatIn)
But it still only did 01/01/1988
Data matrix is as follows: Full Date = G(:,1); Year = G(:,2); Temp data = G(:,3);
Then I just want to output new date to be: year (column 1), month(column 2), day(column 3) and temperature data (column 4)
Any help appreciated.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2016년 7월 29일
편집: Andrei Bobrov 2016년 7월 29일
bed variant (Now I do not have access to MATLAB and use the Octave):
f = fopen('FB_DSAT_1988to2005with year_USE.txt');
c = textscan(f,'%s','delimiter','\n');
fclose(f);
c = c{:}(~cellfun(@isempty,c{:}));
z = regexp(c,'(\-)?\d*(\.)?','match');
zz = cell2mat(cellfun(@(x)str2double([x(3:-1:1) [x{5:end}]]),z,'un',0));
mean daily:
[dly,~,ii] = unique(zz(:,1:3),'rows');
out = [dly, accumarray(ii,zz(:,end),[],@mean)];
  댓글 수: 4
Ice lady
Ice lady 2016년 7월 29일
Dear Andrei, Thanks very much. Appears to work a treat after adding some extra script to display and save to a writable file. Thanks once again. Wish I had asked for some assistance earlier.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by