MATLAB: How to count repeated character in string ?

count repeated character

string loke this aaaaddccccfeeee how to count the repeating of character (a) a=3

Best Answer

str='aaaaddccccfeeee'
[ii,jj,kk]=unique(str)
freq=histc(kk,1:numel(ii))
c=regexp(ii,'.','match')'
out=[c num2cell(freq)]