Convert matrix with 3 columns ([day month year]) into one string dd/mm/yyyy with each part taking value of one column
조회 수: 9 (최근 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!