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

10 views (last 30 days)
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:
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
xlabel('Velocidad de viento promedido diaria[m/s]'), ylabel('Cantidad de días del año TMYV');
ax2 = gca;
ax2.XTickLabelRotation = 45;
h = openfig('histogram.fig');
y = findobj(h, 'type', 'histogram')
Thank you so much for your valious time.

Accepted Answer

Cris LaPierre
Cris LaPierre on 11 Aug 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.
This is the result based on the data you shared.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by