%% Categorical Mask with Specified Length
% Consider a region-of-interest (ROI) table mask with four regions of interest spanning samples numbered from 2 to 30. Specify the category labels as A and B. Use the mask to create a signalMask object.

roiTbl = table([2 5; 7 10; 15 25; 28 30],["A","B","B","A"]');

m = signalMask(roiTbl);

%
% Extract a categorical mask from the object specifying a sequence length of 35. Samples beyond the 30th are returned as <undefined>.

catSeq = catmask(m,35);

catSeq(max(roiTbl.Var1(end)):end)

% Extract the categorical mask again, but now specify a sequence length of 8. Samples beyond the eighth are removed.

catSeq = catmask(m,8)

% Copyright 2020 The MathWorks, Inc.