%% Merge Overlapping Regions of Interest
% Consider a two-column matrix of integers that can represent regions of interest of a signal. Merge any regions that are separated by four samples or less. The function merges overlapping regions in all cases.

rois = [1 10; 17 26; 24 32; 36 40];

xrois = mergesigroi(rois,4)

%
% Specify the maximum separation as zero to merge contiguous or repeated regions.

nrois = [rois; 41 45; 1 10];

xrois = mergesigroi(rois,0)

% Copyright 2020 The MathWorks, Inc.