PlotXY - Plot two columns of a matrix against each other. Plot the second column of a matrix as a function of the first column. Optionally, alternative pairs of columns can be plotted against each other. USAGE p = PlotXY(X,columns,<options>) X the data to plot columns optional pair of columns to plot <options> options for function <a href="matlab:help plot">plot</a>
0001 function varargout = PlotXY(X,varargin) 0002 0003 %PlotXY - Plot two columns of a matrix against each other. 0004 % 0005 % Plot the second column of a matrix as a function of the first column. 0006 % Optionally, alternative pairs of columns can be plotted against each other. 0007 % 0008 % USAGE 0009 % 0010 % p = PlotXY(X,columns,<options>) 0011 % 0012 % X the data to plot 0013 % columns optional pair of columns to plot 0014 % <options> options for function <a href="matlab:help plot">plot</a> 0015 % 0016 0017 % Copyright (C) 2004-2018 by Michaƫl Zugaro 0018 % 0019 % This program is free software; you can redistribute it and/or modify 0020 % it under the terms of the GNU General Public License as published by 0021 % the Free Software Foundation; either version 3 of the License, or 0022 % (at your option) any later version. 0023 0024 if nargin < 1, 0025 error('Incorrect number of parameters (type ''help <a href="matlab:help PlotXY">PlotXY</a>'' for details).'); 0026 end 0027 if nargin >= 2 & isdvector(varargin{1},'#2','>0'), 0028 % Parameter #2 is a pair of column numbers 0029 if size(X,2) == 1, 0030 p = plot(X,varargin{2:end}); 0031 else 0032 p = plot(X(:,varargin{1}(1)),X(:,varargin{1}(2)),varargin{2:end}); 0033 end 0034 else 0035 if size(X,2) == 1, 0036 p = plot(X,varargin{:}); 0037 else 0038 p = plot(X(:,1),X(:,2),varargin{:}); 0039 end 0040 end 0041 0042 % The following code prevents the function returning a handle when no output is expected: 0043 if nargout > 0, 0044 varargout{1} = p; 0045 end