DateTime stamps in uitable from thingSpeakRead() data
显示 更早的评论
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};
采纳的回答
更多回答(2 个)
Cris LaPierre
2020-5-19
编辑:Cris LaPierre
2020-5-19
Try using uifigure instead of figure. We don't have access to your channel, so here's a quick mockup I did using a public channel. To support multiple data types in the output, I also had to add the "OutputFormat","table" Name-Value pair to thingSpeakRead.
chnId = 841669;
[data, chnX] = thingSpeakRead(chnId,'Fields',[1, 2],...
'NumPoints', 5, ...
"OutputFormat","table");
% Visualize data with a uitable
f = uifigure();
uit = uitable(f);
uit.Data = data;
uit.ColumnName = {'Date','A1','A2'};
uit.Position = [5 5 450 150]; %[left bottom width height]
uit.ColumnWidth = {150,65,65};
4 个评论
Cris LaPierre
2020-5-20
编辑:Cris LaPierre
2020-5-20
Moved reply from Mark Keihl so it is a comment instead of an Answer
Cris,
Channel ID: 1044636 is public.
chnId = 1044636;
apiReadKey = 'SJS9JQYUSJSJZYW3';
[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};
Your code never includes the datetime stamps from chnX (data doesn't include the datetime stamps from chnX). Changing "[data, chnX] = " to "data = " resolves that.
Your changes generate this error:
Unable to run the 'Table of Particle device digital inputs' function, because it is not supported for this product offering.
Caused by:
Error using matlab.internal.lang.capability.Capability.require (line 81)
This functionality is not available on remote platforms.
Cris LaPierre
2020-5-20
编辑:Cris LaPierre
2020-5-20
The channel I used contains a timestamp in the data field, which then gets displayed in the uitable.
Could you provide the code that is producing the error?
Mark Kiehl
2020-5-20
编辑:Mark Kiehl
2020-5-20
Cris LaPierre
2020-5-20
I'm not getting an error. What version of MATLAB are you using?
社区
更多回答在 ThingSpeak Community
类别
在 帮助中心 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!