How to create a histogram for 12 months using a time table?
7 ビュー (過去 30 日間)
古いコメントを表示
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
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
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')
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
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 Center および File Exchange で Descriptive Statistics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!