FREQTABLE Frequency table.
[Y,N] = FREQTABLE(X) takes a vector X and returns the unique values of
X in theoutput Y, and the number of instances of each value in the
output N. X can be a charachter array or cell array of strings.
Mukhtar Ullah (2021). FREQTABLE (https://www.mathworks.com/matlabcentral/fileexchange/6631-freqtable), MATLAB Central File Exchange. Retrieved .
ok, i had a transposed vector in the last try(see last review). surely [1; 1+find(diff(S))] instead of [find(diff(S)); end] does not change anything in terms of performance ;-))
i changed the code line after "S=..." to:
B = S([ 1 1+find(diff(S)) ]);
and now it works for me, too. Without the change i got the message: ??? Error using ==> vertcat
CAT arguments dimensions are not consistent.
This function now supports character arrays and cell arrays of strings.
In fact, you have pointed out a limitation:
this file can't be used for cell arrays; for cells use tabulate(statistic toolbox)
Just one question: how to use this with cell array?
Many thanks in advance.
Thanks us! I have rewritten the file according to your suggestions. Your idea is really clever.
no need to use unique. for large Xs this else-code becomes faster for obvious reasons. note histc is a mexed function.
x=sort(xx(:)); % same conditioning
d=diff(x); % same conditioning
% else code
just a thought, us
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!