% [val, num] = howmany(x)
% counts the number of occurrences of finite values in x
% in: x vector of nnumbers (array will be reshaped to a vector)
% out: val unique values in x, sorted
% num number of occurrences
Pekka Kumpulainen (2020). howmany Counts occurrencies of numbers in array (https://www.mathworks.com/matlabcentral/fileexchange/25734-howmany-counts-occurrencies-of-numbers-in-array), MATLAB Central File Exchange. Retrieved .
The exact equal match is intentional in this function. I have another function: "isclose" for the "close enough" comparisons.
But a good suggestion anyway, I might add that option.
It would be nice if this checked for floating point differences as well.
a = [0 0.1 0.2 0.3 0.4];
b = [0:0.1:0.4];
>> [v n] =howmany([a b])
Because the arrays a and b are essentially equal (within eps):
1 1 1 1 1
you should at least give an option to count them as the same number.
Just my two cents