Convert matrix with 3 columns ([day month year]) into one string dd/mm/yyyy with each part taking value of one column
7 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!