My dataset consists of a time vector (30min step) a vector of wind speeds and a vector of wind directions.
I find the cases when wind direction is, for example, nort-northeast using x=find(WD>0&WD<60
and then i use histogram(T.Hour(x),[0 2 4 6 8 10 12 14 16 18 20 22 24]) to derive to a histogram of absolute frequencies of the north-northeast wind in each of the 2hour bins.
How can i plot a histogram with the average wind speed of this specific wind in each 2hour interval?

 Respuesta aceptada

José-Luis
José-Luis el 31 de Ag. de 2017

0 votos

t1 = datetime(2016,6,1,0,30,0);
t2 = datetime(2017,5,31,23,30,0);
t = t1:minutes(30):t2;
wind_dir = randi(360,numel(t),1);
wind = rand(numel(t),1);
idx = wind_dir >= 320 & wind_dir <=360;
t_sub = t(idx);
wind_sub = wind(idx);
result = accumarray(hour(t_sub).' + 1, wind_sub,[],@mean);
bar(result)

2 comentarios

Dimitrios Bentis
Dimitrios Bentis el 31 de Ag. de 2017
Editada: Dimitrios Bentis el 31 de Ag. de 2017
It works! thank you very much!!
is there a way to have the average speed of 2hour intervals (as in the histogram with the frequencies) and not the average speed of each hour?
Once again thank you for your valuable help and guidance.
José-Luis
José-Luis el 31 de Ag. de 2017
result = accumarray(ceil((hour(t_sub)+1)./2).' , wind_sub,[],@mean);

Iniciar sesión para comentar.

Más respuestas (1)

José-Luis
José-Luis el 31 de Ag. de 2017

0 votos

You could adapt a rose plot to your need. It is the "standard" way of showing wind direction distributions.

5 comentarios

Dimitrios Bentis
Dimitrios Bentis el 31 de Ag. de 2017
This wouldn't work because i want an average wind speed (of the specific wind) per 2 hour interval.
So in the x axis i will have the time (with 2 hour intervals) and each bin (attached to a 2 hour interval) will show the average wind speed of that wind in that 2 hour interval. The y axis is of course the average wind speed.
José-Luis
José-Luis el 31 de Ag. de 2017
I don't get it. You already have the average and you say you want to calculate it.
Please show some input data and expected output. As a minimum working example please.
Dimitrios Bentis
Dimitrios Bentis el 31 de Ag. de 2017
What i have so farm is a histogram of absolute frequencies of occurance of a specific wind during each 2 hour interval (example below)
What i am trying to get is a similar histogram but with the average wind speed, of this specific wind, per 2hour interval. So instead of frequency in y axis i would like to have wind speed (but the average wind speed of each bin). I hope this is more helpfull.
Thanks
José-Luis
José-Luis el 31 de Ag. de 2017
Hard to answer if we don't know what your data look like. How is it stored? How's it structured?
Dimitrios Bentis
Dimitrios Bentis el 31 de Ag. de 2017
i have defined my time vector (t) as follows:
t1 = datetime(2016,6,1,0,30,0);
t2 = datetime(2017,5,31,23,30,0);
t = t1:minutes(30):t2;
the data that i have are 2 vectors corresponding to wind speed and direction (WS, WD)
then i used:
x=find(WD>=320&WD<=360);
to find when the desired wind occurs. then with
histogram(t.Hour(x),[0 2 4 6 8 10 12 14 16 18 20 22 24]);
i take the histogram i show above.
what i would like to plot now is the average wind speed of each the bins in the histogram above. In that histogram the bins represent frequency of occurrence.
Thank you for your fast responses.
*if something is unclear ask for clarification.

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Preguntada:

el 31 de Ag. de 2017

Comentada:

el 31 de Ag. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by