]> Creatis software - CreaPhase.git/blob - octave_packages/tsa-4.2.4/histo.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / tsa-4.2.4 / histo.m
1 function [H,X]=histo(Y,Mode)
2 % HISTO calculates histogram for each column
3 % [H,X] = HISTO(Y,Mode)
4 %          
5 %   Mode 
6 %       'rows' : frequency of each row
7 %       '1x'   : single bin-values 
8 %       'nx'   : separate bin-values for each column
9 %   X  are the bin-values 
10 %   H  is the frequency of occurence of value X 
11 %
12 % HISTO(Y) with no output arguments:
13 %       plots the histogram bar(X,H)
14 %
15 % more histogram-based results can be obtained by HIST2RES2  
16 %
17 % see also:  HISTO, HISTO2, HISTO3, HISTO4
18 %
19 % REFERENCE(S):
20 %  C.E. Shannon and W. Weaver "The mathematical theory of communication" University of Illinois Press, Urbana 1949 (reprint 1963).
21
22 %       $Id: histo.m 5148 2008-06-27 10:36:37Z schloegl $
23 %       Copyright (C) 1996-2002,2008 by Alois Schloegl <a.schloegl@ieee.org>    
24 %       This is part of the TSA-toolbox 
25 %       http://hci.tugraz.at/~schloegl/matlab/tsa/
26 %
27 %    This program is free software: you can redistribute it and/or modify
28 %    it under the terms of the GNU General Public License as published by
29 %    the Free Software Foundation, either version 3 of the License, or
30 %    (at your option) any later version.
31 %
32 %    This program is distributed in the hope that it will be useful,
33 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
34 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
35 %    GNU General Public License for more details.
36 %
37 %    You should have received a copy of the GNU General Public License
38 %    along with this program.  If not, see <http://www.gnu.org/licenses/>.
39
40 if nargin<2,
41         Mode='1x';
42 end;
43 Mode=lower(Mode);
44
45 if strcmp(Mode,'rows')
46         R = histo4(Y);
47         
48 elseif strcmp(Mode,'column')
49         R = histo4(Y');
50         R.X = R.X';
51         
52 elseif strcmp(Mode,'1x')
53         R = histo3(Y);
54         
55 elseif strcmp(Mode,'nx')
56         R = histo2(Y);
57         
58 end;
59
60 H = R.H;
61 X = R.X;
62 if nargout == 0,
63         if any(size(X)==1),
64                 if exist('OCTAVE_VERSION')<5,
65                         bar(R.X,R.H,'stacked');
66                 else
67                         bar(R.X,R.H);   
68                 end
69         else
70                 warning('2-dim X-values not supported\n')
71                 %bar3(R.X,R.H);
72         end;
73 end;