Home > utility > cumHistCount.m

cumHistCount

PURPOSE ^

cumHistCount: Find the count of x that is smaller than elements in edges

SYNOPSIS ^

function count=cumHistCount(x, edges, plotOpt)

DESCRIPTION ^

 cumHistCount: Find the count of x that is smaller than elements in edges
    Usage: count=cumHistCount(x, edges)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function count=cumHistCount(x, edges, plotOpt)
0002 % cumHistCount: Find the count of x that is smaller than elements in edges
0003 %    Usage: count=cumHistCount(x, edges)
0004 
0005 if nargin<1; selfdemo; return; end
0006 if nargin<3, plotOpt=0; end
0007 
0008 edges2=[-inf; edges(:)];
0009 count=histc(x, edges2);
0010 count=cumsum(count);
0011 count=count(1:end-1);
0012 
0013 if plotOpt
0014     plot(edges, count, 'o-');
0015     xlabel('X smaller than');
0016     ylabel('Counts');
0017 end
0018 
0019 % ====== Self demo
0020 function selfdemo
0021 x=rand(1000, 1);
0022 edges=0.1:0.1:1;
0023 plotOpt=1;
0024 count=cumHistCount(x, edges, plotOpt);

Generated on Tue 01-Jun-2010 09:50:34 by m2html © 2003