フィルターのクリア

How to create a frequency distribution table

29 ビュー (過去 30 日間)
Eslam
Eslam 2023 年 3 月 8 日
編集済み: Drew 2023 年 5 月 4 日
I have hourly recorder data for wave height and wave direction, so I want to create a frequency distribution table for this data by grouping it.
Maybe the attached picture explains what I need exactly.
Appreciate your help .
  1 件のコメント
Mathieu NOE
Mathieu NOE 2023 年 3 月 13 日
Look for heatmap topics / examples on this forum and on the File exchange

サインインしてコメントする。

回答 (1 件)

Drew
Drew 2023 年 5 月 4 日
編集済み: Drew 2023 年 5 月 4 日
From the raw data, you can use histcounts2 (https://www.mathworks.com/help/matlab/ref/histcounts2.html) to get the number of data points that fall in each joint occurrence bin. You can control the bin edges, etc, if desired. A similar question was answered with histcounts2: https://www.mathworks.com/matlabcentral/answers/268207-how-to-bin-data-based-on-two-variables-to-create-a-joint-occurance-table?s_tid=prof_contriblnk
Once you have the counts, you can normalize them and visualize them in various ways, including with heatmap, hist3, or with histogram2. If using a heatmap, you can adjust the heatmap chart properties with https://www.mathworks.com/help/matlab/ref/matlab.graphics.chart.heatmapchart-properties.html
% jotw = Joint Occurrence Table for Waves
% This is data from the image above
jotw=[1.1 0.3 0 0 0 0 0 0 0 0.1 0.4 1.4
1.8 1.2 0.3 0.1 0 0.7 0 0 0.1 0.1 2.1 3.1
1.8 1.9 0.3 0 0 0 0 0 0 0.5 5.3 5.8
1.6 1.2 0 0 0 0 0 0 0 0.7 5.9 7.4
0.6 0.2 0 0 0 0 0 0 0 0.5 5.9 6.0
0.4 0.2 0 0 0 0 0 0 0 0.6 4.0 6.6
0.3 0 0 0 0 0 0 0 0 0.5 2.8 6.0
0.2 0 0 0 0 0 0 0 0 0.5 2.3 2.9
0 0 0 0 0 0 0 0 0 0.4 2.1 2.0
0 0 0 0 0 0 0 0 0 0.2 1.2 1.1
0 0 0 0 0 0 0 0 0 0.2 1.0 0.9
0 0 0 0 0 0 0 0 0 0 0.8 0.4
0 0 0 0 0 0 0 0 0 0 0.6 0.2
0 0 0 0 0 0 0 0 0 0 0.4 0.2
0 0 0 0 0 0 0 0 0 0 0.4 0.1
0 0 0 0 0 0 0 0 0 0 0.7 0.3
0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0];
% Change zeros to NaNs so that the zeros can be made invisible
jotw(jotw==0)=NaN;
h=heatmap(jotw);
% Adjust the label and color of the NaNs
h.MissingDataLabel="no data";
h.MissingDataColor=h.Colormap(1,:);
% Can alternately get these from the bin centers or bin edges if the data
% is from histcounts2
h.XData={'0','30','60','90','120','150','180','210','240','270','300','330'};
h.YData={'0.0-0.2','0.2-0.2','0.4-0.6','0.6-0.8','0.8-1.0','1.0-1.2','1.2-1.4', ...
'1.4-1.6','1.6-1.8','1.8-2.0','2.0-2.2','2.2-2.4','2.4-2.6','2.6-2.8', ...
'2.8-3.0','3.0-4.0','4.0-5.0','>5.0'};
% Add some labels
h.XLabel='Mean Wave Direction';
h.YLabel='Significant Wave Height (m)';
h.Title='% Occurrence of Wave Height and Wave Direction';

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by