MATLAB: DateTime stamps in uitable from thingSpeakRead() data

datetimestampMATLABThingSpeakuitable

I cannot figure out how to add the date/time stamp data in chnX to the uitable without generating an error.
chnId = #######;
apiReadKey = 'thingspeak-api-read-key';
[data, chnX] = thingSpeakRead(chnId, 'Fields',[1, 2, 3, 4, 5, 6], ...
'NumPoints', 5, ...
'ReadKey', apiReadKey);
% Visualize data with a uitable
f = figure();
uit = uitable(f);
uit.Data = data;
uit.ColumnName = {'A0','A1','A2','A3','A4','A5'};
uit.Position = [5 5 450 150]; %[left bottom width height]
uit.ColumnWidth = {65,65,65,65,65,65};

Best Answer

My apologies for not catching onto that initially. While uifigure is needed to add datetimes, it is not supported in ThingSpeak. You can find a list of the table properties and their accepted inputs here. From that link, you can see that only numeric, logical, or cell arrays can be passed to the Data property of uitables created with the figure function.
Option 1
You could just display the table without trying to put it into a uitable.
chnId = 1044636;
apiReadKey = 'SJS9JQYUSJSJZYW3';
data = thingSpeakRead(chnId, 'Fields',[1, 2, 3, 4, 5, 6], ...
'NumPoints', 5, ...
'ReadKey', apiReadKey);
% Visualize data
varNames = {'A0','A1','A2','A3','A4','A5'};
Tbl = array2timetable(data,'RowTimes',chnX,'VariableNames',varNames)
Option 2
If you really want it in a table, and
  1. don't want to compress the date to a single numeric representation (datenum), and
  2. also don't want to split the date into parts (datevec), creating a column for each one (Y,M,D,h,m,s)
the answer is to create a cell array. To do this, you need to turn the dates into a character array (datestr), and then turn the combined data into a cell array. The easiest way I could find to do that was with table2cell, which meant I first had to turn the data into a table (array2table).
I noticed there is a maximum width allowed for a uitable, so I had to adjust the formatting of the timestamp to get all the columns to fit.
Here is what I came up with.
%% Read Data %%
[data, chnX] = thingSpeakRead(1044636, ...
'Field', [1, 2, 3, 4, 5, 6], ...
'NumPoints', 5);
%% Convert chnX + data to a cell array %%
Tbl = array2table(data);
Tbl.timestamp = datestr(chnX,'mm/dd/yy HH:MM');
Tbl = movevars(Tbl,"timestamp","Before",1);
tblData = table2cell(Tbl);
%% Visualize Data with a uitable %%
f = figure;
uit = uitable(f);
% uit.Data = [dates(:,1),dates(:,2:3)*[1;.01],dates(:,4:6)*[60;1;1/60],data];
uit.Data = tblData;
uit.ColumnName = {'Timestamp','A0','A1','A2','A3','A4','A5'};
uit.Position = [5 5 590 150]; %[left bottom width height]
uit.ColumnWidth = {130,65,65,65,65,65,65};