% Channel ID to read data from readChannelID = 772570; % Channel Read API Key readAPIKey = 'G69NOS1HEH299SKP'; % One day date range dateRange = [datetime('today') datetime('now')]; % Read data including the timestamp, and channel information. [data,time,channelInfo] = thingSpeakRead(readChannelID,'Fields',1:4, 'DateRange',dateRange); % Create variables to store different sorts of data vent_mini_jour = data(:,1); vent_moyen_jour = data(:,2); vent_maxi_jour = data(:,3); vent_dir_jour = data(:,4); %orientation du terrain (0 à 15) terrainDir = 2.5; % Orientation du vent rad = (2*pi)-(vent_dir_jour*2*pi/16)+(3*pi/2); % les directions du jour, en radians radt= (2*pi)-(terrainDir*2*pi/16)+(3*pi/2); % la direction de la piste, en radians % composantes pour les vecteurs dans la boussole ut = cos(radt); vt = sin(radt); % GRAPHE figure ax=polaraxes; angles = 0:45:360; labels = {'E','NE','N','NO','O','SO','S','SE'}; Vent_max = max(vent_maxi_jour); polarhistogram(ax, rad,(0-pi/16:2*pi/16:2*pi)) % Plot the wind direction histogram in a polar axis max_hist=rlim; % récupère le rayon max de l'histogramme hold on; Echelle = max_hist(end)*(30/(Vent_max+0.1)); % +0.1 pour éviter de diviser par 0! polarplot([0 radt+pi],[0 Echelle],'-g','LineWidth',10); % la direction de la piste polarplot([0 radt],[0 Echelle],'-g','LineWidth',10); % la direction de la piste dans l'autre sens polarhistogram(ax, rad,(0-pi/16:2*pi/16:2*pi)) % Plot the wind direction histogram in a polar axis polarplot([0 rad(end)], [0 Echelle*(vent_moyen_jour(end)+5)/20], '-w','LineWidth',8); % la direction du vent polarplot([0 rad(end)], [0 Echelle*(vent_moyen_jour(end)+5)/20], ':r','LineWidth',8); % la direction du vent %polarplot([0 rad(end)], [0 Echelle + 0.2], ':r','LineWidth',8); % la direction du vent %title('Direction actuelle'); ax.ThetaTick = angles; ax.ThetaTickLabel = labels; ax.ThetaGrid = 'on'; ax.RGrid = 'off'; ax.RTickLabel = []; annotation('textbox', [0.01, 0.9, 0.1, 0.1], 'string', vent_maxi_jour(end) , 'color', 'r','FontWeight','bold','FontSize', 12, 'LineStyle', 'none') annotation('textbox', [0.01, 0.83, 0.1, 0.1], 'string', vent_moyen_jour(end) , 'color', 'k','FontWeight','normal','FontSize', 12, 'LineStyle', 'none' ) annotation('textbox', [0.01, 0.75, 0.1, 0.1], 'string', vent_mini_jour(end) , 'color', 'g','FontWeight','normal','FontSize', 10, 'LineStyle', 'none' ) annotation('textbox', [0.01, 0.001, 0.1, 0.1], 'string', datestr(time(end),'dd/mm/yy HH:MM') , 'color', 'k','FontWeight','normal','FontSize', 6, 'LineStyle', 'none' ) set(gcf,'position',[0,0,300,300]) hold off;