halfway merged and pulled?!
This commit is contained in:
31
Functions/Metrics/count_error_bursts.m
Normal file
31
Functions/Metrics/count_error_bursts.m
Normal file
@@ -0,0 +1,31 @@
|
||||
function burst_count = count_error_bursts(err_pos, max_burst_length)
|
||||
% err_pos: Vector of error positions
|
||||
% max_burst_length: Maximum length for which bursts are counted (e.g., 10)
|
||||
|
||||
% Sort the error positions to ensure they're in increasing order
|
||||
err_pos = sort(err_pos);
|
||||
|
||||
% Initialize burst_count array to hold the counts for each burst length
|
||||
burst_count = zeros(1, max_burst_length);
|
||||
|
||||
% Find the differences between consecutive error positions
|
||||
diffs = diff(err_pos);
|
||||
|
||||
% Find the start of the bursts (where the difference is greater than 1)
|
||||
burst_starts = [1, find(diffs > 1) + 1]; % Starts at index 1 and after gaps
|
||||
burst_ends = [find(diffs > 1), length(err_pos)]; % Ends where gaps are
|
||||
|
||||
% Loop over the bursts
|
||||
for b = 1:length(burst_starts)
|
||||
burst_length = burst_ends(b) - burst_starts(b) + 1;
|
||||
|
||||
% Check if the burst length exceeds any of the thresholds
|
||||
for i = 1:max_burst_length
|
||||
if burst_length == i
|
||||
burst_count(i) = burst_count(i) + 1;
|
||||
else
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user