matlab count how many elements are smaller than code example Example: number of values lager than matlab x=50*rand(7); a= x > 21; numel(a(a>0))