MATLAB: How to convert 0’s and 1’s to intergers

not sure what tags are

For example i have an array of ones and zeros, 100 total.(00000,1111111111,0000000000000,11111…). How can i count them, and return integers for example (0,1,2,4,3,1,..)

Best Answer

If that happens to be a string of characters, try:
cac = regexp( '000001111111111000000000000011111', '(0+)|(1+)', 'match' );
cellfun( @(s) numel(s), cac )
You have to check whether it starts with "1" or "0"