I am facing a problem inserting a table with my data from thingspeak to a matlab uitable in guide.
When I press a button, i run the following code to put the data into the uitable (created with guide before):
data = thingSpeakRead(<ChannelID>, 'DateRange',[datetime('Oct 27, 2016'),datetime('Nov 4, 2016')],'OutputFormat','table')
and this is the result in the command window:
Timestamps Fahrer Kilometerstand Fahrtgrund
____________________ _________ ______________ ________________
27-Oct-2016 18:15:25 0 0 'Initialisieren'
27-Oct-2016 18:17:01 217314240 0 'Dienstfahrt'
27-Oct-2016 18:17:34 0 13 'Fahrtende'
27-Oct-2016 18:18:05 741914369 13 'Analyse'
27-Oct-2016 18:18:36 0 20 'Fahrtende'
Error using matlab.ui.control.Table/set
While setting the 'Data' property of Table:
Data must be a numeric, logical, or cell array
Error in Test_Download>pushbutton1_Callback (line 82)
Error in gui_mainfcn (line 95)
Error in Test_Download (line 42)
Error in @(hObject,eventdata)Test_Download('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
When i don't use the 'OutputFormat','table'-Option in ThingSpeakRead it works, but then the timestamp and the last coloumn with the strings are missing. Which is bad, because they are necessary for my application.
I don't know how to access the datatypes properly to get everything running. Can anybody help me with this?
Thanks a lot!
UITABLE is currently supported only on MATLAB Desktop and MATLAB Online. It is not supported on ThingSpeak.
An error is generated by your code because UITABLE at present does not support TABLE and DATETIME types in MATLAB. Therefore, when you read data from ThingSpeak with outputFormat set to Table, the returned table isn't supported by UITABLE. To work around this, here is some example code:
% Read data from a channel as a table
data = thingSpeakRead(1417, 'DateRange',[datetime('Oct 27, 2016'),datetime('Oct 28, 2016')], 'outputFormat', 'table');
% Create an empty UITABLE
t = uitable;
% Convert the timestamps in the table to string format (from datetime type)
data.Timestamps = datestr(data.Timestamps);
% Convert the table to a MATLAB Cell array
cellData = table2cell(data);
% Assign the data to UITABLE
t.Data = cellData;
Let us know if this doesn't resolve the issue.
thank you for your reply. I did the same thing with my table and formated all vectors to cell array data.
Here is some example code for others facing the same problem:
%T1 was datetime-variable
%T2 is Num-variable
%T3 is num-variable
%T4 is cell-variable
Thanks again for your help!
Most Users Ever Online: 114
Currently Browsing this Page:
Guest Posters: 1
Administrators: Hans, lee