Displaying dates instead of minutes in 3 day comparison
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
im using the matlab visualization to compare and display my temperature data.
Is there a way to show the date and time instead of the the last 1400 minutes?
% Read temperature data from a ThingSpeak channel for three seperate days
% and visualize the data in a single plot using the PLOT function.
% Channel 12397 contains data from the MathWorks Weather Station, located
% in Natick, Massachusetts. The data is collected once every minute.
% Field 4 contains temperature data.
% Channel ID to read data from
readChannelID = xxx;
% Temperature Field ID
myFieldID = 3;
% One day date range
oneDay = [datetime('yesterday') datetime('today')];
% Channel Read API Key
% If your channel is private, then enter the read API key between the '' below:
readAPIKey = '';
% Read Temperature Data. Learn more about the THINGSPEAKREAD function by
% going to the Documentation tab on the right side pane of this page.
temperatureDay1 = thingSpeakRead(readChannelID,'Fields',myFieldID, ...
'dateRange', oneDay, 'ReadKey',readAPIKey);
temperatureDay2 = thingSpeakRead(readChannelID,'Fields',myFieldID, ...
'dateRange',oneDay-days(1),'ReadKey',readAPIKey);
temperatureDay3 = thingSpeakRead(readChannelID,'Fields',myFieldID, ...
'dateRange', oneDay-days(2),'ReadKey',readAPIKey);
% Create array of durations
myTimes1 = minutes(1:length(temperatureDay1));
myTimes2 = minutes(1:length(temperatureDay2));
myTimes3 = minutes(1:length(temperatureDay3));
% Visualize the data
plot(myTimes1,temperatureDay1, myTimes2,temperatureDay2, myTimes3, temperatureDay3);
legend({'Day1','Day2','Day3'});
% datetick('x',13,'keepticks');
xlabel('Minuten');
ylabel('Temperatur');
title('3-Tage Temperatur Vergleich Raum');
greetings
0 Kommentare
Antworten (1)
Christopher Stapels
am 10 Jan. 2022
Bearbeitet: Christopher Stapels
am 10 Jan. 2022
The temperature example you used is a way to compare three different ranges of times onthe same plot. You can read the timestamps from the channel and use them to plot instead of what is in the example. In thingSpeakRead, you can use the 'outputformat', 'timetable', and then access the timestamps in temperatureDay1.Timestamps.
myData=thingSpeakRead(chid,...'outputformat','timetable');
plot(myData.Timestamps,myData.Var1); % Var1 is the field name. or you can use .(1) for field 1
if your data had drastically different scales, you can use yyaxis right between plot calls to plot on the right axis.
plot(...data1)
yyaxis right
plot(...data2...)
You can also get the times from ThingSpeak with the format
[data,timestamps] = thingSpeakRead(...);
2 Kommentare
Communitys
Weitere Antworten in ThingSpeak Community
Siehe auch
Kategorien
Mehr zu Read Data from Channel finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!