I have a Matlab table with three columns: Year, Month, Day. I want to make it into one column that represents the date in a format 'MM/dd/yyyy'. How can I do that? I tried quite a while to no avail, but I believe someone may know it immediately. Thanks.
The Table T has 3 columns (Year, Month, Day) and 10 rows.

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2015년 8월 7일
편집: Andrei Bobrov 2015년 8월 7일
T = [randi([2014 2016],10,1),randi([1 12],10,1),randi([1 28],10,1)];
out = datestr(datenum(T),'mm/dd/yyyy');

댓글 수: 2

JFz
JFz 2015년 8월 7일
Wow. It works! Exactly what I wanted to have! Thank you so much!
JFz
JFz 2015년 8월 7일
Curious, how does Matlab know which column is for Year, whichis for month? In the code, you didn't specify which column goes where?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

JFz
2015년 8월 7일

댓글:

JFz
2015년 8월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by