This seems to work:
a = [1 1 1 1 0 0 1 1 1 0 0 0 0 1 0 0 0 0 1 0
0 1 1 1 1 1 1 0 0 1 1 0 0 0 0 1 0 1 0 0
1 1 1 0 0 0 0 1 0 1 0 0 1 0 1 0 1 0 0 0
0 0 0 1 0 0 1 0 1 0 1 1 1 1 1 1 0 0 0 1]
[rows, columns] = size(a)
for row = 1 : rows
thisRow = a(row,:)
counter = 0;
for col = 1 : 4 : columns
counter = counter + 1;
thisSegment = thisRow(col:col+3)
f = find(thisSegment);
if ~isempty(f)
output{row, counter} = col+f - 1;
end
end
end
celldisp(output)
Best Answer