How to create a histogram for 12 months using a time table?

조회 수: 12 (최근 30일)
Wolfgang McCormack
Wolfgang McCormack 2021년 5월 21일
댓글: Adam Danz 2021년 6월 10일
Hi all,
I have a time table with 365 days (hourly). I want to create a histogram which shows how many values above 50 exists in each month. Could you please instruct me on how to do that?
The time table has multiple columns.
Thank you all in advance.
  댓글 수: 1
Scott MacKenzie
Scott MacKenzie 2021년 6월 9일
편집: Scott MacKenzie 2021년 6월 9일
@Wolfgang McCormack Seems to me what you are really after is a bar chart: 1 bar for each month with the height of the bar equal to the number of values > 50 (recorded hourly in the month). Is that correct?
It would help if you posted the data so we can see the organization of the table and the sort of "values" that are in it.

댓글을 달려면 로그인하십시오.

답변 (1개)

Adam Danz
Adam Danz 2021년 6월 10일
편집: Adam Danz 2021년 6월 10일
% Create demo timetable
dates = datetime(1999,1,1,'Format','MMM') + hours(0:364*24)';
TT = timetable(dates, randi([25,75],size(dates)),'VariableNames',{'Data'});
% Add column indicating values of "Data" over 50
TT.IsOver = TT.Data > 50;
% Count number of values of 50 per month
MT = retime(TT,'monthly','sum')
MT = 12×2 timetable
dates Data IsOver _____ _____ ______ Jan 37770 371 Feb 33387 309 Mar 37413 363 Apr 35963 351 May 37326 363 Jun 36279 363 Jul 36980 351 Aug 37181 372 Sep 35649 342 Oct 36812 340 Nov 35912 354 Dec 36595 381
The resultant timetable MT contains the columns "IsOver" showing the number of values of "Data" that are over 50 for each row.
  댓글 수: 1
Adam Danz
Adam Danz 2021년 6월 10일
If your table is large, you can place the IsLarge column within its own table since that's the only column that you need to apply retime.

댓글을 달려면 로그인하십시오.

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by