Cutoff Threshold of data points

I have calculated the sum of rainfall per rainfall event [RF_Total(x,:) ] and the sum of hours in that event [RF_Hours(x,:)]. I would like to remove rainfall events that are greater that 50.8 mm and more than 51h. This is what I've developed thus far.
(I've attached a compressed file containing the data that you would need for line 1 )
M1 = readmatrix('Pevents.txt'); % Text File to Matrix
NaNv = find(isnan(M1)); % Numeric Indices Of 'NaN' Values
NaNv = [NaNv; size(M1,1)]; % Last Index (Instead Of Last 'NaN') Is The End Of The Vector
Events = 1:numel(NaNv)-1;
for x = Events
idxrng = NaNv(x)+2:NaNv(x+1)-1;
RF_Vector{x,:} = M1(idxrng); % Vector Of Rainfall Events (Between 'NaN' Elements)
RF_Hours(x,:) = numel(idxrng); % Number Of Hours In Each Event (h)
RF_Total(x,:) = sum(M1(idxrng)); % Sum Of Rainfall Data (mm)
end
t_holdrain = 50.8; % Cutoff Threshold of Rainfall Data(mm)
t_holdhr = 51; % Cutoff Threshold of Hourly Rainfall(h)
y(x,:) = RF_Total(x,:);
z(x,:) = RF_Hours(x,:);
if y(y > t_holdrain)& z(z > t_holdhr) % Excluding rainfall greater than the threshold
end

Answers (1)

Try this:
y(x,:) = RF_Total(x,:);
z(x,:) = RF_Hours(x,:);
% Determine what rows we want to eliminate.
rowsToDelete = (y > t_holdrain) & (z > t_holdhr); % Excluding rainfall greater than the threshold
% Now remove them from y and z
y(rowsToDelete, :) = [];
z(rowsToDelete, :) = [];

5 Comments

RF_Total =
2.8000
3.3000
15.2400
1.2600
1.7800
1.7800
1.0100
1.0100
3.5500
1.5300
0.7600
1.5200
1.5300
19.5600
40.6400
0.7600
1.2700
8.1200
6.8500
4.5700
37.3500
47.5000
4.8200
1.2700
21.5900
7.6000
16.7600
10.1500
13.7200
3.3000
1.2700
3.8000
0.7600
10.4100
6.3500
3.5400
2.7900
7.6200
2.2800
24.3800
2.2800
16.7600
4.8300
33.7800
22.5900
0.7600
11.4300
9.9000
18.2800
8.1300
7.3500
4.5600
13.2000
0.7600
2.0300
3.8100
9.9100
2.5400
11.6900
9.3900
25.8900
16.7500
58.6700
127.2400
2.5400
2.0400
26.4100
30.7200
4.3200
2.2900
8.1200
2.5400
35.3000
12.9500
9.1300
3.0500
2.2700
3.5600
14.7300
8.1200
5.0800
0.7600
4.0600
7.1000
1.5200
7.8500
0.7600
0.7600
9.9000
9.9000
20.8300
9.6400
20.0700
66.0300
3.0400
13.8700
11.5000
0.7500
3.2700
0.7500
1.0000
2.0000
1.0000
1.0000
1.0000
0.7500
1.0000
2.7500
53.9700
0.7500
0.7600
2.0300
10.6400
6.6000
4.8300
2.5400
1.2600
6.8500
7.3600
5.0700
2.2900
2.2800
1.0200
4.5600
2.2900
2.7900
0.7500
1.7700
15.2400
3.2900
1.0100
0.7500
3.0400
21.5300
0.7500
11.0500
0.7500
1.0100
5.8300
0.7600
5.8200
3.0300
1.5100
7.2500
0.7500
0.7500
1.2500
0.7500
0.7500
1.0000
1.2500
0.7500
1.0100
2.5400
1.2700
5.0900
2.0300
11.4300
3.5500
18.7900
88.1200
1.2500
0.7500
52.2100
3.5100
47.7400
16.2400
3.0400
7.1000
9.8900
11.6800
0.7500
6.6000
17.2600
19.8000
48.4800
4.0600
4.0600
1.5200
10.1600
1.2500
129.7400
18.0300
28.9500
17.0000
5.8400
12.6900
54.0900
10.4400
3.3100
12.4500
10.9200
3.3000
2.0300
11.9400
2.0300
4.3100
9.1400
19.8000
28.7100
4.0700
4.0600
21.4600
1.0000
1.2600
4.3100
24.9000
5.3300
23.8700
1.2700
20.0700
20.5600
17.2500
13.1800
14.9700
5.0800
4.5600
0.7600
2.2900
3.8000
1.2700
1.7800
0.7600
3.2900
4.5700
6.8500
5.8400
20.3000
2.5300
1.5300
2.0200
0.7600
1.5100
That didn't quite work because the numerical values were removed.
That's the format of RF_Total and RF_Hours. I would like to remove numbers greater than 50.8 for RF_Total and more than 51 for RF_Hours.
Can you try combining these two and then applying the conditions so that I get the values of the remaining there still.
If you want to remove the row if either condition is true, you can use OR:
rowsToDelete = (y > t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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
20
This is the result I'm getting. I'm not sure where the other data that are below the threshold went.
M1 = readmatrix('Pevents.txt'); % Text File to Matrix
NaNv = find(isnan(M1)); % Numeric Indices Of 'NaN' Values
NaNv = [NaNv; size(M1,1)]; % Last Index (Instead Of Last 'NaN') Is The End Of The Vector
Events = 1:numel(NaNv)-1;
for x = Events
idxrng = NaNv(x)+2:NaNv(x+1)-1;
RF_Vector{x,:} = M1(idxrng); % Vector Of Rainfall Events (Between 'NaN' Elements)
RF_Hours(x,:) = numel(idxrng); % Number Of Hours In Each Event (h)
RF_Total(x,:) = sum(M1(idxrng)); % Sum Of Rainfall Data (mm)
end
Total_Hours = [ RF_Hours, RF_Total];
Okay i think it'll be easier to understand based on how i put it into a vector as Total_Hours.
If a row in column 1 is more than 51 or a row in column 2 is more than 50.8. I would like to remove the entire row.
i got it thanksss

Sign in to comment.

Asked:

on 6 Mar 2022

Commented:

on 8 Mar 2022

Community Treasure Hunt

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

Start Hunting!