frequency of a specific wind direction in a histogram with hourly intervals

조회 수: 4 (최근 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
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개)

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by