How to concatenate table columns into one columns

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.

 Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 7 Aug. 2015
Bearbeitet: Andrei Bobrov am 7 Aug. 2015
T = [randi([2014 2016],10,1),randi([1 12],10,1),randi([1 28],10,1)];
out = datestr(datenum(T),'mm/dd/yyyy');

2 Kommentare

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Tags

Noch keine Tags eingegeben.

Gefragt:

JFz
am 7 Aug. 2015

Kommentiert:

JFz
am 7 Aug. 2015

Community Treasure Hunt

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

Start Hunting!

Translated by