Files
imdd_silas/Functions/Metrics/count_error_bursts.m
Silas Oettinghaus 4099f6820f BCJR implementation
WDM code added (Pol Cont., Opt MUX/DEMUX, Opt Atten, DP_Fiber) -> the codebase is not optimized to always work with dp signals!
2025-09-17 13:58:58 +02:00

32 lines
1.1 KiB
Matlab

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