Average wind speed histogram
11 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
José-Luis
on 31 Aug 2017
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 Comments
José-Luis
on 31 Aug 2017
result = accumarray(ceil((hour(t_sub)+1)./2).' , wind_sub,[],@mean);
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!