[strs,cnt] = cellhist(vals); Counts the number of instances of each string in the cell array vals
0001 function [strs,cnt] = cellhist(vals) 0002 % [strs,cnt] = cellhist(vals); 0003 % 0004 % Counts the number of instances of each string in the cell array vals 0005 % 0006 0007 % 8/27/03 PJ 0008 0009 sorted = sort(vals); 0010 unique_vals = unique(sorted); 0011 nunique = length(unique_vals); 0012 0013 cnt = zeros(1,nunique); 0014 0015 for ival = 1:nunique 0016 cnt(ival) = sum(ismember(sorted,unique_vals{ival})); 0017 end 0018 0019 strs = unique_vals; 0020 0021 return