Effacer les filtres
Effacer les filtres

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

3 vues (au cours des 30 derniers jours)
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.

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 29 Juil 2016
Modifié(e) : Andrei Bobrov le 29 Juil 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 commentaires
Ice lady
Ice lady le 29 Juil 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by