Home > data-analysis > stats > cont > cont_histc.m

cont_histc

PURPOSE ^

Return the histogram of the cont data.

SYNOPSIS ^

function [N,bin] = cont_histc(data, param, flag)

DESCRIPTION ^

 Return the histogram of the cont data.
   [N,bin] = cont_histc(data, param)
   The meaning of N and bin and the PARAM are same with that of the matlab function, histc.
   flag: 
      flag == 'separate', the histogram is calculated for each column of data separatedly
      flag == 'whole',    the histogram is calculated for the whole set of data
 Examples:
   [N, bin] = cont_histc(var, [0 100 200 300 400]);
   [N, bin] = cont_histc(var, [0 100 200 300], 'whole');

 See also: HISTC, CONT_HIST, HIST

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [N,bin] = cont_histc(data, param, flag)
0002 % Return the histogram of the cont data.
0003 %   [N,bin] = cont_histc(data, param)
0004 %   The meaning of N and bin and the PARAM are same with that of the matlab function, histc.
0005 %   flag:
0006 %      flag == 'separate', the histogram is calculated for each column of data separatedly
0007 %      flag == 'whole',    the histogram is calculated for the whole set of data
0008 % Examples:
0009 %   [N, bin] = cont_histc(var, [0 100 200 300 400]);
0010 %   [N, bin] = cont_histc(var, [0 100 200 300], 'whole');
0011 %
0012 % See also: HISTC, CONT_HIST, HIST
0013 %
0014 if ~exist('flag', 'var')
0015     flag = 'separate';
0016 end
0017 
0018 if exist('param', 'var') 
0019     [N,bin] = histc(data(:,2:end), param);
0020 else
0021     error 'HISTC requires bin edge parameters, unlike HIST.'
0022 end
0023 
0024 if strcmp(flag, 'whole')
0025     N = sum(N,2);
0026 elseif ~strcmp(flag, 'separate')
0027     error ['Wrong valude for parameter "flag" -- ', flag];
0028 end
0029 
0030 return;
0031 
0032

Generated on Tue 23-May-2017 20:00:55 by m2html © 2005