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?
Mark Kiehl
2020 年 5 月 21 日
コミュニティ
その他の回答 ThingSpeak コミュニティ
カテゴリ
ヘルプ センター および 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!