Azzera filtri
Azzera filtri

Categorizing groups of data

2 visualizzazioni (ultimi 30 giorni)
Queena Edwards
Queena Edwards il 5 Mar 2022
Commentato: Star Strider il 5 Mar 2022
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 Commenti
Queena Edwards
Queena Edwards il 5 Mar 2022
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.

Accedi per commentare.

Risposta accettata

Star Strider
Star Strider il 5 Mar 2022
Modificato: Star Strider il 5 Mar 2022
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 Commenti
Queena Edwards
Queena Edwards il 5 Mar 2022
Okay. Thanks very much! I’ll see how I can continue to develop the code.
Star Strider
Star Strider il 5 Mar 2022
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Accedi per commentare.

Più risposte (1)

Image Analyst
Image Analyst il 5 Mar 2022
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.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by