Effacer les filtres
Effacer les filtres

date and time convert in number

2 vues (au cours des 30 derniers jours)
Rica
Rica le 15 Nov 2012
Hi
I have :
%
date vector:
a=['1.1.2010';'2.2.2010';'2.5.2010'...]
time vector:
b=['1.2.58';'2.5.52';'4.6.30'.....]
date_time=[a b]
i transform the vector from cell to array with cell2mat and i get
% ab=1.1.20102.2.58
2.2.20102.5.52
2.5.20104.6.30
how could i isert white space between date and time to be able to use datenum?
thank you

Réponse acceptée

Jan
Jan le 15 Nov 2012
Please note, that this definition will fail as soon as any day or month has more than 1 digit:
a = ['1.1.2010'; '2.12.2010'; '2.5.2010']; % ERROR! Different lengths!
For storing string of different size, a cell string is reuquired.
a = ['1.1.2010'; '2.2.2010'; '2.5.2010'];
b = ['1.2.58'; '2.5.52'; '4.6.30'];
c = strcat(cellstr(a), {' '}, cellstr(b));
  1 commentaire
Rica
Rica le 15 Nov 2012
Thanks u are the best!!!

Connectez-vous pour commenter.

Plus de réponses (2)

Sara
Sara le 15 Nov 2012
%date vector:
a={'1.1.2010';'2.2.2010';'2.5.2010'}
% time vector:
b={'1.2.58';'2.5.52';'4.6.30'}
date_time=[a b]

Rica
Rica le 15 Nov 2012
hi!
but you could not use datenum(date_time)!

Catégories

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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by