Home > chronux_1_15 > spikesort > utility > plottypes > mplot.m

mplot

PURPOSE ^

MPLOT Plot rows of a data matrix.

SYNOPSIS ^

function h = mplot(t, matrix, varargin)

DESCRIPTION ^

MPLOT             Plot rows of a data matrix.
   MPLOT(MATRIX) makes a line plot of the rows of an (M x N) matrix using
   a single line object.  For large M, these plots are drawn more quickly
   than PLOT(MATRIX') since only one object is created and that object
   does not undergo front-to-back sorting.

   MPLOT(X,MATRIX). where X is a length N vector, plots the rows of
   MATRIX vs X.
 
   MPLOT(MATRIX, ...) passes additional arguments through to PLOT.

   H = MPLOT(MATRIX) returns a handle to the line object.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function h = mplot(t, matrix, varargin)
0002 %MPLOT             Plot rows of a data matrix.
0003 %   MPLOT(MATRIX) makes a line plot of the rows of an (M x N) matrix using
0004 %   a single line object.  For large M, these plots are drawn more quickly
0005 %   than PLOT(MATRIX') since only one object is created and that object
0006 %   does not undergo front-to-back sorting.
0007 %
0008 %   MPLOT(X,MATRIX). where X is a length N vector, plots the rows of
0009 %   MATRIX vs X.
0010 %
0011 %   MPLOT(MATRIX, ...) passes additional arguments through to PLOT.
0012 %
0013 %   H = MPLOT(MATRIX) returns a handle to the line object.
0014 
0015 %%%%% Parse arguments
0016 if (nargin == 1),  matrix = t;  clear t;  end;
0017 if ((nargin > 1) && ischar(matrix))  % MPLOT(MATRIX, ...) syntax
0018         varargin = {matrix; varargin{:}};
0019         matrix = t;   clear t;
0020 end
0021 if (~exist('t','var')),  t = 1:size(matrix,2);  end;
0022 
0023 [M,N] = size(matrix);
0024 [mm,nn] = size(t);
0025 if (((mm == 1) && (nn == N)) || ((mm == N) & (nn == 1)))
0026     % do nothing here ...
0027 else
0028     error('In MPLOT(X,MATRIX,...), X must be a length N vector when MATRIX is M x N.');
0029 end
0030 
0031 %%%%% Create wraparound indices
0032 inds = repmat([t NaN]', [M,1]);
0033 matrix = padmatrix(matrix, [0 1 0 0], NaN)';  % padding with NaNs keeps wraparounds from being drawn
0034 
0035 %%%%% Do the plot.
0036 h = plot(inds, matrix(:), varargin{:});
0037 
0038 if (nargout < 1), clear h;  end;

Generated on Tue 15-Aug-2006 22:51:57 by m2html © 2003