How to create a frequency distribution table

조회 수: 23 (최근 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 CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by