MATLAB: Counting the values and variables

count

I have a dataset 50x62
for example
S=['F' 'D' 'C' 'D' 'C';'C' 'C' 'F' 'D' 'F']
these variables are my output from one operation,now i want to count the number of variables
here i have 2 rows and number of variable is 3
so i need as
F D C
1 2 2
2 1 2
PLEASE HELP

Best Answer

What about a nice loop:
S=['F' 'D' 'C' 'D' 'C';'C' 'C' 'F' 'D' 'F'];
x = sort(unique(S));
fprintf('%c\t', x')
fprintf('\n')
for ii = 1:size(S, 1)
for jj = 1:length(x)
temp(jj) = length(find(S(ii, :) == x(jj)));
end
fprintf('%d\t', temp);
fprintf('\n')
end