Home > functions > internal > dsIndexToBlocks.m

dsIndexToBlocks

PURPOSE ^

INDEXTOBLOCKS - TODO unclear what this does

SYNOPSIS ^

function blocks = dsIndexToBlocks(index)

DESCRIPTION ^

INDEXTOBLOCKS - TODO unclear what this does

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function blocks = dsIndexToBlocks(index)
0002 %INDEXTOBLOCKS - TODO unclear what this does
0003 
0004 index_length = length(index);
0005 if any(index == 0)
0006     d_index = diff(index);
0007     starts = find(d_index == 1) + 1;
0008     stops = find(d_index == -1);
0009 else
0010     starts = 1;
0011     stops = index_length;
0012 end
0013 
0014 if ~isempty(stops) || ~isempty(starts)
0015     if ~isempty(stops)
0016         if isempty(starts) || stops(1) < starts(1)
0017             starts = [1; starts];
0018         end
0019     end
0020     if ~isempty(starts)
0021         if isempty(stops) || starts(end) > stops(end)
0022             stops = [stops; index_length];
0023         end
0024     end
0025     stops(end) = min(stops(end), index_length);
0026     blocks = [starts stops];
0027 else
0028     blocks = [];
0029 end

Generated on Tue 12-Dec-2017 11:32:10 by m2html © 2005