Home > utils > cellhist.m

cellhist

PURPOSE ^

[strs,cnt] = cellhist(vals);

SYNOPSIS ^

function [strs,cnt] = cellhist(vals)

DESCRIPTION ^

 [strs,cnt] = cellhist(vals);

 Counts the number of instances of each string in the cell array vals

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003