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')

              The following call returns a string that contains the 
              routine CVS version:

              >> version = foo(ao,'Version')

              The following call returns a string that contains the 
              routine category:

              >> category = foo(ao,'Category')

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

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003