% Template MATLAB code for visualizing correlated data using the
% SCATTER function.

% Prior to running this MATLAB code template, assign the channel variables.
% Set 'readChannelID' to the channel ID of the channel to read from.
% Also, assign the read field IDs to the variables 'fieldID1', 'fieldID2', and 'fieldID3'.

% TODO - Replace the [] with channel ID to read data from:
readChannelID = []];
% TODO - Replace the [] with the Field ID to read data from:
fieldID1 = 1;
% TODO - Replace the [] with the Field ID to read data from:
fieldID2 = 2;
% TODO - Replace the [] with the Field ID to read data from:
fieldID3 = 3;

% Channel Read API Key
% If your channel is private, then enter the read API
% Key between the '' below:
readAPIKey = '';


%% Read Data %%

nbMesures = 50
% Read 1 data variable
% data1 = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumPoints', 3000, 'ReadKey', readAPIKey);
[data1, time1] = thingSpeakRead(readChannelID, 'Field', fieldID1, 'NumPoints', nbMesures, 'ReadKey', readAPIKey);

% Read 2 data variable
% data2 = thingSpeakRead(readChannelID, 'Field', fieldID2, 'NumPoints', 3000, 'ReadKey', readAPIKey);
[data2, time2] = thingSpeakRead(readChannelID, 'Field', fieldID2, 'NumPoints', nbMesures, 'ReadKey', readAPIKey);

% Read 3 data variable
% data2 = thingSpeakRead(readChannelID, 'Field', fieldID2, 'NumPoints', 3000, 'ReadKey', readAPIKey);
[data3, time3] = thingSpeakRead(readChannelID, 'Field', fieldID3, 'NumPoints', nbMesures, 'ReadKey', readAPIKey);


%% Visualize Data %%

plot(time1,data1, time2,data2, time3,data3);

legend({'Tout','Tstock','Tin'});
% xlabel('jour');
ylabel('Temperature C');
title('Mesures solaires');
