MATLAB: Find groups of 1’s in array

groupImage Processing Toolboxone

Sorry but ı have asked question wrong.
thanks all for great attention.
For example the data 11101111001110001111110100000000011111111 is like that and there only two groups of 1 could be because number of 0 maybe to few then we should accept them as a 1 how can we do that we have to find 1's group as a 2 there.
Examples: 1111111111100111111111111111011111111111111111= Result:1
1111111111100000000000000000111111111111111111= Result:2
11111111111000000000001111111111110000000001111111111100000000111111111 =Result :4
111111011111111010111111111101111111010011111111101001111111= Result :1
111010101111101000000011100011111 =RESULT :3 LIKE THAT

Best Answer

Nsplit = 5; % number of consecutive zeros that split a group
Z = find(diff(x) == 1) - find(diff(x) == -1);
Ngroups = sum(Z > Nsplit) + 1;