DateTime stamps in uitable from thingSpeakRead() data
Mostra commenti meno recenti
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};
Risposta accettata
Più risposte (2)
Cris LaPierre
il 19 Mag 2020
Modificato: Cris LaPierre
il 19 Mag 2020
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 Commenti
Cris LaPierre
il 20 Mag 2020
Modificato: Cris LaPierre
il 20 Mag 2020
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
il 20 Mag 2020
Modificato: Cris LaPierre
il 20 Mag 2020
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
il 20 Mag 2020
Modificato: Mark Kiehl
il 20 Mag 2020
Cris LaPierre
il 20 Mag 2020
I'm not getting an error. What version of MATLAB are you using?
Mark Kiehl
il 21 Mag 2020
Community
Più risposte nel ThingSpeak Community
Categorie
Scopri di più su Develop Apps Using App Designer in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!