Convert matrix with 3 columns ([day month year]) into one string dd/mm/yyyy with each part taking value of one column
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Loriann Chevalier
am 15 Apr. 2022
Kommentiert: Loriann Chevalier
am 15 Apr. 2022
Hello everybody,
I have a matrix Nx3 called Date with 3 columns describing "random" dates. First column is day, second is month and third is year, like this :
1 3 1981
28 3 1982
23 3 1983
9 5 1984
27 3 1985
15 2 1986
19 2 1987
16 4 1988
20 3 1989
etc.
I want to write a vector with one single column that has the form :
01/03/1981
28/03/1982
23/03/1983
etc.
I tried to use the datestr() function like this :
datestr(Date,'dd/mm/yyyy')
but it returns me a vector of length Nx3 (i.e. size 3Nx1) :
'01/01/0000'
'28/01/0000'
'23/01/0000'
'09/01/0000'
'27/01/0000'
'15/01/0000'
'19/01/0000'
'16/01/0000'
'20/01/0000'
'02/01/0000'
etc.
I do not understand what is wrong with datestr().
Is there another function that would put all the 3 columns in one, and adding a zero in front of the numbers of days or months with only one digit (i.e. also write 1 as 01) ?
Cheers
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!