Home > classes > @ao > stairs.m

stairs

PURPOSE ^

STAIRS overloads the stairs function for Analysis Objects.

SYNOPSIS ^

function varargout = stairs(varargin)

DESCRIPTION ^

 STAIRS overloads the stairs function for Analysis Objects.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: STAIRS overloads the stairs function for Analysis Objects.

 CALL:            stairs(a)
              h = stairs(a,pl)

 INPUTS:      a  - analysis object(s)
              pl - parameter list(s)

 OTPUTS:      h  - plot handles

 PARAMETERS:

              The following call returns a parameter list object that
              contains the default parameter values:

              >> pl = stairs(ao, 'Params')

 VERSION:     $Id: stairs.m,v 1.4 2007/07/12 15:56:44 ingo Exp $

 HISTORY: 02-03-07 M Hewitson
            Creation.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function varargout = stairs(varargin)
0002 % STAIRS overloads the stairs function for Analysis Objects.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: STAIRS overloads the stairs function for Analysis Objects.
0007 %
0008 % CALL:            stairs(a)
0009 %              h = stairs(a,pl)
0010 %
0011 % INPUTS:      a  - analysis object(s)
0012 %              pl - parameter list(s)
0013 %
0014 % OTPUTS:      h  - plot handles
0015 %
0016 % PARAMETERS:
0017 %
0018 %              The following call returns a parameter list object that
0019 %              contains the default parameter values:
0020 %
0021 %              >> pl = stairs(ao, 'Params')
0022 %
0023 % VERSION:     $Id: stairs.m,v 1.4 2007/07/12 15:56:44 ingo Exp $
0024 %
0025 % HISTORY: 02-03-07 M Hewitson
0026 %            Creation.
0027 %
0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0029 
0030 % Check if this is a call for parameters
0031 if nargin == 2
0032   if isa(varargin{1}, 'ao') && ischar(varargin{2})
0033     in = char(varargin{2});
0034     if strcmp(in, 'Params')
0035       varargout{1} = getDefaultPL();
0036       return
0037     end
0038   end
0039 end
0040 
0041 %---------------- Standard history variable
0042 
0043 ALGONAME = mfilename;
0044 VERSION  = '$Id: stairs.m,v 1.4 2007/07/12 15:56:44 ingo Exp $';
0045 
0046 %---------------- capture input variable names, AOs, and plists
0047 invars = {};
0048 as     = [];
0049 ps     = [];
0050 Nbins  = -1;
0051 Xbins  = [];
0052 for j=1:nargin
0053   if isa(varargin{j}, 'ao')
0054     invars = [invars cellstr(inputname(j))];
0055   end
0056   if isa(varargin{j}, 'ao')
0057     as = [as varargin{j}];
0058   end
0059   if isa(varargin{j}, 'plist')
0060     ps = [ps varargin{j}];
0061   end
0062   if isnumeric(varargin{j})
0063     if length(varargin{j}) > 1
0064       Xbins = varargin{j};
0065     else
0066       Nbins = varargin{j};
0067     end
0068   end
0069 end
0070 
0071 % produce one plist
0072 if isa(ps, 'plist')
0073   pl = combine(ps, getDefaultPL());
0074 else
0075   pl = getDefaultPL();
0076 end
0077 
0078 % If we have X from command input, override plist
0079 if ~isempty(Xbins)
0080   pl = set(pl, 'X', Xbins);
0081 end
0082 
0083 % If we have N from command input, override plist
0084 if Nbins>0
0085   pl = set(pl, 'N', Nbins);
0086 end
0087 
0088 % number of input AOs
0089 na = length(as);
0090 
0091 
0092 % Get parameters
0093 N = find(pl, 'N');
0094 X = find(pl, 'X');
0095 
0096 colors  = {[0.8 0.2 0.2], [0.2 0.2 0.8], [0.2 0.9 0.2],...
0097     [0.37 0.9 0.83], [0.888 0.163 0.9], [0 0 0], ...
0098     [0 207 255]/255, [255 128 0]/255, [143 0 0]/255,...
0099     [255 207 0]/255, [0.9 0.266 0.593]};
0100 
0101 %---------------- Loop over input AOs
0102 
0103 % Initialise output
0104 handles = [];
0105 % start looping
0106 for j=1:na
0107   a = as(j);
0108   legendStr = [];
0109 
0110   % get data
0111   [x,y] = getAOdata(a);
0112   if isempty(x)
0113     x = 1:length(y);
0114   end
0115 
0116   % make stair plot
0117   col = colors{mod(j-1,length(colors))+1};
0118   h = stairs(x,y);
0119   legendStr = [legendStr cellstr(sprintf('%s', ltpda_label(a.name)))];
0120   set(h, 'Color', col);
0121   title('Stair plot');
0122   grid on;
0123   legend(legendStr)
0124   ylabel(sprintf('Y [%s]', a.data.yunits));
0125   xlabel(sprintf('X [%s]', a.data.xunits));
0126   hold on;
0127 
0128   % store handles for output
0129   handles = [handles h];
0130 
0131 end
0132 
0133 %---------------- Set outputs
0134 if nargout == 1
0135   varargout{1} = handles;
0136 end
0137 %--------------------------------------------------------------------------
0138 % Get default params
0139 function plo = getDefaultPL()
0140 
0141 disp('* creating default plist...');
0142 plo = plist();
0143 plo = append(plo, 'N', '');
0144 plo = append(plo, 'X', '');
0145 disp('* done.');
0146 
0147 
0148 % END

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003