problem with datenum: it does not return the same number for the same date
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi everybody,
I have a problem with datenum. I have some operations to do on dates. The problem is the following one: for the same date, datenum does not return the same number... that's a problem. My comands:
dnum = datenum(Date(1:n),'dd/mm/yyyy');
dnumCRB = datenum(DateCRB(1:n3),'dd/mm/yyyy');
whos Date DateCRB
Name Size Bytes Class Attributes
Date 1756x1 231572 cell
DateCRB 1756x1 230572 cell
[Date(1:10) DateCRB(1:10)]
ans =
'09/10/2008' '09/10/2008'
'10/10/2008' '10/10/2008'
'13/10/2008' '13/10/2008'
'14/10/2008' '14/10/2008'
'15/10/2008' '15/10/2008'
'16/10/2008' '16/10/2008'
'17/10/2008' '17/10/2008'
'20/10/2008' '20/10/2008'
'21/10/2008' '21/10/2008'
'22/10/2008' '22/10/2008'
[dnum(1:10) dnumCRB(1:10)]
ans =
733661 733661
733662 733690
733663 733691
733666 733694
733667 733695
733668 733696
733669 733697
733670 733698
733673 733701
733674 733702
Do you know what's happened here?
Thank you very much for your help,
Best,
Thomas
0 commentaires
Réponses (1)
Azzi Abdelmalek
le 3 Juil 2015
Modifié(e) : Azzi Abdelmalek
le 3 Juil 2015
If we check this, there is no problem
s={'09/10/2008' '09/10/2008'
'10/10/2008' '10/10/2008'
'13/10/2008' '13/10/2008'
'14/10/2008' '14/10/2008'
'15/10/2008' '15/10/2008'
'16/10/2008' '16/10/2008'
'17/10/2008' '17/10/2008'
'20/10/2008' '20/10/2008'
'21/10/2008' '21/10/2008'
'22/10/2008' '22/10/2008'}
d1=s(:,1)
d2=s(:,2)
dnum=datenum(d1,'dd/mm/yyyy')
dnumCRB=datenum(d2,'dd/ mm/ yyyy ')
[dnum dnumCRB]
We can check the problem, if you attach your data file
2 commentaires
Campion Loong
le 6 Juil 2015
Thomas, You file does not look entirely comma-separated. Some fields have numbers attached followed by semicolons.
Will you also post the code you use to import these to generate the 'Date' & 'DateCRB' variables in the first place?
Voir également
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!