from count (mex) by Stefano Gianoli
Counts the number elements in a specified vector or matrix that match a specified criteria.

count.m
% RES = COUNT(MATRIX,X,COND)
%   Given a vector or matix MATRIX, counts the number of times that 
%   the scalar X satisfy the (string) condition COND. The result
%   is returned in the variable RES. the COND operators allowed are: 
%   ==, >=, <=, <, >, !=. d
%   The function is faster than SUM(MATRIX'COND'X) or LENGTH(FIND(MATRIX'COND'X))
%   
%
% EXAMPLE:
% 
% >> count(1:10,2,'<=')
% 
% ans =
% 
%      2

Contact us at files@mathworks.com