Stupid Matlab Hacks
Count occurrences of elements in a vector

Snippet:

[elements x]=unique(sort([1 2 3 4 4 4 5 5 4]));

count=diff([0 x]);


elements =
     1     2     3     4     5
count =
     1     1     1     4     2
  1. stupidmatlabhacks posted this