 function decData = collapse_text(decData)
%

%   Copyright 1990-2008 The MathWorks, Inc.
     if all([decData.isActive])
         return;
     end
    ranges = find_inactive_ranges([decData.isActive]);
    for idx = size(ranges,2):-1:1
        r1 = ranges(1,idx);
        r2 = ranges(2,idx) - 1;
        if r1 ~= r2 
            text = decData(r1).text;
            fs = num2str(r1);
            text = strrep(text,fs,[fs '-' num2str(r2)]);
            decData(r1).text = text;
            decData(r1 + 1 : r2) = [];
        end
    end

function ranges = find_inactive_ranges(isActive)
     d = [1 isActive] - [isActive 1];
     [g lr] = find(d>0);
     [g rr] = find(d<0);
     ranges = [lr ; rr ];
