%% Merge 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.

rois = [1 10; 17 26; 28 43; 47 57; 64 66];

xrois = mergesigroi(rois,4)

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

nrois = [rois; 57 65; 1 10];

xrois = mergesigroi(rois,0)

% Copyright 2020 The MathWorks, Inc.