outerjoin between timetables changing the time format
Afficher commentaires plus anciens
Hi, I am attaching the variable.mat that contains g8067525, g8072050 table variables. I was trying to join them (after filling the time series gaps with NaNs) using outerjoin function. However, it changes the time format from "24-Aug-2017 00:00:00" to "24-Aug-2017" in the output file. Basically it is ignoring the hh:mm:ss part. I highly appreciate your help to make it showing the full time format. Thanks a lot.
t1 = datetime(2017,8,24,0,0,0); % start of simulation/usgs gage reading
t2 = datetime(2017,9,1,0,0,0); % end of simulation/usgs age reading
t3 = t1:minutes(15):t2; % 15 minutes interval
t=t3'; % make it column vector
x={g8067525, g8072050}
TT=timetable();
for k=1:length(x)
x1=table2timetable(x{k});
x2=retime(x1,t);
TT=outerjoin(TT,x2);
end
T= timetable2table(TT);
writetable(T,'usgs.dat','Delimiter','\t')
6 commentaires
Adam Danz
le 4 Nov 2020
I could not reproduce this problem in r2020b.

Shuvashish Roy
le 4 Nov 2020
Peter Perkins
le 18 Nov 2020
In recent versions of MATLAB, the "default" display of datetimes became more intelligent about whether or not a time portion needs to be displayed, which is why Adam doesn't see what you see.
I think this is because TT's (empty) row times had no time portion, so their display was set to "don't need to show a time portion". When combining datetime arrays with different formats, the first one "wins", so the result ended up using TT's format because it was first in your outerjoin call. I bet if you flipped the inputs to outerjoin you'd get your time back.
In any case, you can set the .Format in your result to 'default' and that should do it. But as I said, since R2019-something, this is no longer an issue. And just to be clear (and you already know this), it was just a display issue: the values were not losing their time portion, on the display.
Shuvashish Roy
le 18 Nov 2020
You can set the format of the time column named "Time" in a timetable TT using
TT.Time.Format = 'dd-MMM-uuuu HH:mm:ss'; % Or whatever format you want to use
Shuvashish Roy
le 18 Nov 2020
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Variables dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



