COUNTS = ROWCOUNT(VALUES, LOOKUPVALUES)
Written in c, so the operation is fast. Type "mex rowcount.c" in matlab before use.
You might need a free compiler if it was not installed with your matlab:
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.