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.
 
 Usage:      stairs(a)
         h = stairs(a,pl)
 
 Inputs:
   a  - analysis object(s)
   pl - parameter list(s)
 
 Outputs:
   h  - plot handles
 
 Parameters:
   
 
 M Hewitson 24-05-07
 
 $Id: stairs.html,v 1.1 2007/06/08 14:15:03 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

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

Generated on Fri 08-Jun-2007 16:09:11 by m2html © 2003