Categorizing groups of data

조회 수: 4 (최근 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일
Image Analyst the read matrix worked but the findgroups is not in the format I want.
Going back to the file I sent, the first event is 9h. The second event is 1h. The third event is 5h.
The seventh event is also 5h long. I would like to group the third, seventh and any other 5h events out of the 250.
Afterwards, using this 5h group. The rainfall would be summed for each hour and then divided into 9 intervals
This is repeated for the 1h group, 2h group …to the 24h group.
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
Queena Edwards
Queena Edwards 2022년 3월 5일
Okay. Thanks very much! I’ll see how I can continue to develop the code.
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.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by