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)

 INPUTS:      a  - analysis object(s)

 OTPUTS:      h  - plot handles

 PARAMETERS:  none

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

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

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

Generated on Thu 01-Nov-2007 09:42:34 by m2html © 2003