% countchars(str, charset): count how often
% each char in <charset> appears in <str>
% Example: 
% countchars('hello', 'aeiou') => 0 1 0 1 0
function cnts = countchars(str, charset)
cnts = zeros(1,length(charset)); 
%!! The accumulator 
for k=1:length(charset) 
   cnts(k) = sum(str == charset(k));
end