How to make an histogram for month with datetime series, the data is windvelocity for a 1 year?

16 visualizaciones (últimos 30 días)
Hi everybody, thank you so much for reading me, i really appreaciate, so i have a little problem, is very simple i think, i want to do an histogram for every months, i have my data in datetime, and i have the wind velocity, but i want to know the frequency of the data for months, but i don't know what i can't
this is my code right now:
clear;clc;
numData = xlsread('enerosolar.xlsx','EneDicV')
vel = numData(:,1);
Dia = numData(:,2);
tEnersol=readtable('enerosolar.xlsx','Sheet','EneDicV'); % read into a table object
tEnersol.Properties.VariableNames={'Vel','Dia'}; % assign variable names
yr=2014; % need the proper year
tEnersol.Date=datetime(yr,1,tEnersol.Dia); % and create a date column
tEnersol.Date.Format='dd/MM'; % display date format
hB=bar(tEnersol.Vel); % bar plot in descending order vs ordinal position
hAx=gca; % get axes handle...
xticks(1:7:365) % about all the ticks there's room for...
xticklabels(cellstr(tEnersol.Date(xticks))) % use the date string as tick labels
hAx.XTickLabelRotation=45; % rotate so can have chance to read...
xlabel('Dia del año'), ylabel('Velocidad de viento promedido diaria[m/s]');
perc = hline(2.85154314702398,'r', 'Velocidad de viento promedio '); hold on
perc = hline(2.85154314702398,'r', '2.85 m/s '); hold on
% perc = hline(4,'r', '4-3 m/s'); hold on
% perc = hline(3,'r', '3-1 m/s'); hold on
figure(2)
histogram(day(tEnersol.Vel))
xlabel('Velocidad de viento promedido diaria[m/s]'), ylabel('Cantidad de días del año TMYV');
ax2 = gca;
ax2.XTickLabelRotation = 45;
savefig('histogram.fig');
h = openfig('histogram.fig');
y = findobj(h, 'type', 'histogram')
figure(4)
Thank you so much for your valious time.
Best!!
Sophia

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 11 de Ag. de 2020
I don't think you want to do histograms. Try a boxplot instead. Boxplots convey information about the spread of the data, but in a manner that makes it easy to compare the results from each month of the year.
boxplot(vel,month(tEnersol.Date),"Labels",month(tEnersol.Date,"shortname"))
This is the result based on the data you shared.
  4 comentarios

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Weather and Atmospheric Science en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by