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