% Channel ID to read data from readChannelID = 772570; % Channel Read API Key readAPIKey = 'G69NOS1HEH299SKP'; % One day date range dateRange = [datetime('yesterday','TimeZone','Europe/Paris') datetime('now','TimeZone','Europe/Paris')]; % Read data including the timestamp [data,time] = thingSpeakRead(readChannelID,'Fields',5,'DateRange',dateRange); % Create variables to store different sorts of data tension = data(:,1)/100; %coefficient correcteur sur le pont diviseur tension = tension*1.072; time1=time + hours(2) % GRAPHE v(1)=plot(time1, tension,'b','LineWidth',1) % Plot hold on uistack(v(1),'top'); xlabel('Horaire') ylabel('tension (V)') ylim([11 15]) xlim([time(1) time1(end)]) % coloriage des zones fill([xlim fliplr(xlim)], [11 11 11.5 11.5], 'r', 'LineStyle', 'none', 'FaceAlpha', 0.1) % Highlight the uncomfortable zone text(0.7*datenum(time(1)) + 0.3*datenum(time(end)), 75, 'tension faible', 'FontWeight','bold') fill([xlim fliplr(xlim)], [11.5 11.5 15 15], 'g', 'LineStyle', 'none', 'FaceAlpha', 0.1) % Highlight the comfortable zone text(0.7*datenum(time(1)) + 0.3*datenum(time(end)), 60, 'ok', 'FontWeight','bold') % Add text for the zone title(sprintf('%s : %.3g V', datestr(time1(end),'dd/mm/yy HH:MM'), tension(end)),'FontSize', 8, 'FontWeight', 'normal') set(gcf,'position',[0,0,800,800]) ax=gca ax.XAxis.FontSize = 8; ax.YAxis.FontSize = 8; hold off