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.

 Accepted Answer

T = [randi([2014 2016],10,1),randi([1 12],10,1),randi([1 28],10,1)];
out = datestr(datenum(T),'mm/dd/yyyy');

2 Comments

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

Sign in to comment.

More Answers (0)

Categories

Tags

No tags entered yet.

Asked:

JFz
on 7 Aug 2015

Commented:

JFz
on 7 Aug 2015

Community Treasure Hunt

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

Start Hunting!