DateTime stamps in uitable from thingSpeakRead() data
Mostrar comentarios más antiguos
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};
Respuesta aceptada
Más respuestas (2)
Cris LaPierre
el 19 de Mayo de 2020
Editada: Cris LaPierre
el 19 de Mayo de 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 comentarios
Cris LaPierre
el 20 de Mayo de 2020
Editada: Cris LaPierre
el 20 de Mayo de 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
el 20 de Mayo de 2020
Editada: Cris LaPierre
el 20 de Mayo de 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
el 20 de Mayo de 2020
Editada: Mark Kiehl
el 20 de Mayo de 2020
Cris LaPierre
el 20 de Mayo de 2020
I'm not getting an error. What version of MATLAB are you using?
Mark Kiehl
el 21 de Mayo de 2020
Comunidades de usuarios
Más respuestas en ThingSpeak Community
Categorías
Más información sobre Develop Apps Using App Designer en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!