Filter löschen
Filter löschen

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

3 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 29 Jul. 2016
Bearbeitet: Andrei Bobrov am 29 Jul. 2016
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 Kommentare
Ice lady
Ice lady am 29 Jul. 2016
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by