how to create array datetime
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i want datetime in this format :
01/02/2008 501 (day/month/years and time)
i try it :
bbb=datetime(bb,"InputFormat", "dd/MM/yyyy");
but i get error format
1 commentaire
Cris LaPierre
le 13 Mai 2024
Based on your graphic, 01/02/2008 501 is actually (month/day/year time)
Réponse acceptée
Voss
le 13 Mai 2024
load matlab_A
A
hh = floor(A(:,4)/100);
mm = mod(A(:,4),100);
ss = zeros(size(A,1),1);
B = [A(:,[1 2 3]) hh mm ss];
D = datetime(B,'Format','dd/MM/yyyy Hmm')
6 commentaires
Stephen23
le 20 Mai 2024
Note that by supplying the units separately you could minimize the seconds to one single 0 and write less code:
A = load('matlab_A.mat').A
hh = fix(A(:,4)/100);
mm = mod(A(:,4),100);
D = datetime(A(:,1),A(:,2),A(:,3),hh,mm,0, 'Format','dd/MM/yyyy Hmm')
Plus de réponses (2)
Cris LaPierre
le 13 Mai 2024
Modifié(e) : Cris LaPierre
le 13 Mai 2024
You have the correct function, just the wrong syntax. The biggest issue I see with the conversion is that your time appears to be in millitary format, or HHmm.
I therefore think the simplest approach is to convert your array into a string arrary and then use the syntax t = datetime(DateStrings)
load matlab_A.mat
A
% Capture the time
D = datetime(num2str(A),'InputFormat',"yyyy M d Hmm",'Format',"dd/MM/yyyy Hmm")
0 commentaires
Voir également
Catégories
En savoir plus sur Audio and Video Data 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!