PlotSamples - Plot samples (multiple time series). Plot columns 2...M of a matrix as a function of its first column. USAGE p = PlotSamples(X,<options>,<options2>) X <a href="matlab:help samples">samples</a> to plot <options> optional list of property-value pairs (see table below) <options2> options for function <a href="matlab:help plot">plot</a> ========================================================================= Properties Values ------------------------------------------------------------------------- 'spacing' vertical spacing between variables (default = 1 for point processes, 0 for continuous data) =========================================================================
0001 function p = PlotSamples(X,varargin) 0002 0003 %PlotSamples - Plot samples (multiple time series). 0004 % 0005 % Plot columns 2...M of a matrix as a function of its first column. 0006 % 0007 % USAGE 0008 % 0009 % p = PlotSamples(X,<options>,<options2>) 0010 % 0011 % X <a href="matlab:help samples">samples</a> to plot 0012 % <options> optional list of property-value pairs (see table below) 0013 % <options2> options for function <a href="matlab:help plot">plot</a> 0014 % 0015 % ========================================================================= 0016 % Properties Values 0017 % ------------------------------------------------------------------------- 0018 % 'spacing' vertical spacing between variables (default = 1 for point 0019 % processes, 0 for continuous data) 0020 % ========================================================================= 0021 % 0022 0023 % Copyright (C) 2004-2011 by Michaƫl Zugaro 0024 % 0025 % This program is free software; you can redistribute it and/or modify 0026 % it under the terms of the GNU General Public License as published by 0027 % the Free Software Foundation; either version 3 of the License, or 0028 % (at your option) any later version. 0029 0030 if nargin < 1, 0031 error('Incorrect number of parameters (type ''help <a href="matlab:help PlotSamples">PlotSamples</a>'' for details).'); 0032 end 0033 0034 % Default values 0035 pointProcess = false; 0036 spacing = []; 0037 v = {}; 0038 0039 % Parse parameter list 0040 n = 1; 0041 for i = 1:2:length(varargin), 0042 if ~ischar(varargin{i}), 0043 error(['Parameter ' num2str(i+2) ' is not a property (type ''help <a href="matlab:help PlotSamples">PlotSamples</a>'' for details).']); 0044 end 0045 switch(lower(varargin{i})), 0046 case 'spacing', 0047 spacing = varargin{i+1}; 0048 if ~isdscalar(spacing), 0049 error('Incorrect value for property ''spacing'' (type ''help <a href="matlab:help PlotSamples">PlotSamples</a>'' for details).'); 0050 end 0051 0052 case 'type', 0053 type = lower(varargin{i+1}); 0054 if ~isastring(type,'continuous','point'), 0055 error('Incorrect value for property ''type'' (type ''help <a href="matlab:help PlotSamples">PlotSamples</a>'' for details).'); 0056 end 0057 pointProcess = strcmp(type,'point'); 0058 0059 otherwise, 0060 v = varargin{i:end}; 0061 if ~isa(v,'cell'), v = {v}; end 0062 break; 0063 end 0064 end 0065 0066 if isempty(spacing), 0067 if pointProcess, 0068 spacing = 1; 0069 else 0070 spacing = 0; 0071 end 0072 end 0073 0074 % Plot 0075 hold on; 0076 if pointProcess, 0077 for i = 1:size(X,2), 0078 PlotTicks(X(:,i),(i-1)*spacing,'direction','v',v{:}); 0079 end 0080 else 0081 for i = 2:size(X,2), 0082 plot(X(:,1),(i-1)*spacing+X(:,i),v{:}); 0083 end 0084 end 0085