MATLAB: How to add a column of today’s date to a table

MATLAB

Hi,
I have a table vTbl with several columns. I would like to add one more column with dates in it. And all the cells in that new column is just today/s date in the format of "mm/dd/yyyy". But I just can't get it right. I tried:
todayDate = datetime('now','Format','MM/dd/yyyy');
vdates = cell(size(vTbl, 1), 1);
todayeDateStr = datestr(todayDate, 'MM/dd/yyyy');
vdates(:) = (todayDateStr);
vTbl = [ table(vdates', 'VariableNames', {'VDate'}) vTbl];
But I keep getting error:
The following error occurred converting from char to cell:
Error using cell
Conversion to cell from char is not possible.
I am stuck here. Thanks for any help.
Jennifer

Best Answer

I had to create ‘vTbl’, but this code should work regardless of what it is:
strs = char(randi([double('A') double('Z')], 5, 3)); % Create Variable
vTbl = table(strs, 'VariableNames',{'Strings'}); % Create ‘vTbl’
todayDate = datestr(now,'mm/dd/yyyy'); % Create Date String
datesvct = repmat(todayDate, size(vTbl,1), 1); % Create ‘Vector’ Of Date String
vTbl = [ table(datesvct, 'VariableNames', {'VDate'}) vTbl]; % Concatenate Dates In Table