frequency of a specific wind direction in a histogram with hourly intervals
2 次查看(过去 30 天)
显示 更早的评论
Hello,
I have 2 vectors (datetime, wind direction). How could i plot a histogram with 2 hour bins (0-2,2-4...22-24) showing the frequency of the wind direction being between 100 and 150 degrees during each of the above intervals.
Thank you very much!
4 个评论
Will Nitsch
2017-5-2
Try this:
%%create a bunch of random data
times = [];
windDir = [];
for i = 1:10
times = [times,randperm(24)];
% Note that not all wind directions will be between 100-150 deg
windDir = [windDir, rand(1,24)*360];
end
%%Get the winds with a direction between 100 and 150:
windsIdx = find(windDir <= 150 & windDir >= 100);
hFig = figure;
counts = histcounts(times(windsIdx),[0,2,4,6,8,10,12,14,16,18,20,22,24]);
hHist = histogram('Categories',{'0:00-2:00','2:00-4:00','4:00-6:00','6:00-8:00','8:00-10:00','10:00-12:00','12:00-14:00','14:00-16:00','16:00-18:00','18:00-20:00','20:00-22:00','22:00-24:00'},'BinCounts',counts);
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!