Cutoff Threshold of data points

3 次查看(过去 30 天)
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

回答(1 个)

Image Analyst
Image Analyst 2022-3-6
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 个评论
Queena Edwards
Queena Edwards 2022-3-8
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Numeric Types 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by