Categorizing groups of data

1 ビュー (過去 30 日間)
Queena Edwards
Queena Edwards 2022 年 3 月 5 日
コメント済み: Star Strider 2022 年 3 月 5 日
I separated rainfall data into 250 events. Each rainfall event has different number of points. I want to classify all the events with 4 points together, 5 points together, 6 points together and so on.
  8 件のコメント
Queena Edwards
Queena Edwards 2022 年 3 月 5 日
Use this data

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

採用された回答

Star Strider
Star Strider 2022 年 3 月 5 日
編集済み: Star Strider 2022 年 3 月 5 日
See if the findgroups function will do what you want.
EDIT — (5 Mar 2022 at 17:36)
Uz = unzip('https://www.mathworks.com/matlabcentral/answers/uploaded_files/915459/Rainfallevents.zip')
Uz = 1×1 cell array
{'Rainfallevents/Pevents.txt'}
T1 = readtable(Uz{1})
T1 = 3807×1 table
Var1 ____ NaN 1 0.51 0 0 0 0 1.27 0 0 1.02 NaN 2 3.3 NaN 3
[G,ID] = findgroups(T1{:,1})
G = 3807×1
NaN 5 3 1 1 1 1 7 1 1
ID = 318×1
0 0.2500 0.5100 0.7600 1.0000 1.0200 1.2700 1.5200 1.7800 2.0000
Gu = unique(G); % Unique Groups
This file at least has something in it.
What am I supposed to do with this information?
What is the desired result?
.
  17 件のコメント
Star Strider
Star Strider 2022 年 3 月 5 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2022 年 3 月 5 日
Try this:
data = readmatrix('pevents.txt')
% Convert nans to zeros
data(isnan(data)) = 0;
% Set rain days to 1;
rainDays = logical(data)
% Measure lengths of all rain events.
props = regionprops(rainDays, 'Area')
% Get the lengths of all the rain events into a single vectore.
allLengths = [props.Area];
% Show a histogram of the lengths
histogram(allLengths);
title('Distribution of Rain Storms in Days');
xlabel('Length of Rain in Days');
ylabel('Number of Events of this Length')
grid on;
fprintf('Mean length of rainstorm = %.2f days.\n', mean(allLengths));
fprintf('Median length of rainstorm = %.2f days.\n', median(allLengths));
fprintf('Longest length of rainstorm = %.2f days.\n', max(allLengths));
Mean length of rainstorm = 2.80 days.
Median length of rainstorm = 2.00 days.
Longest length of rainstorm = 209.00 days.

Community Treasure Hunt

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

Start Hunting!

Translated by