issamples - Test if parameter is a list of samples satisfying an optional list of tests. A list of <a href="matlab: help Samples">samples</a> is a vector or matrix of doubles containing at least one column for (sorted) timestamps, and optionally more for continuous variables. USAGE test = issamples(x,test1,test2,...) x parameter to test test1... optional list of additional tests (see examples below) EXAMPLES % Test if x is a list of samples issamples(x) % Special test: test if x is a point process (i.e. 1 column) issamples(x,'#0') % Special test: test if x contains 3 variables (i.e. 4 columns) issamples(x,'#3') SEE ALSO See also isdmatrix, isdvector, isdscalar, isimatrix, isivector, isiscalar, isastring, islscalar, islvector, islmatrix.
0001 %issamples - Test if parameter is a list of samples satisfying an optional list of tests. 0002 % 0003 % A list of <a href="matlab: help Samples">samples</a> is a vector or matrix of doubles containing at least one column 0004 % for (sorted) timestamps, and optionally more for continuous variables. 0005 % 0006 % USAGE 0007 % 0008 % test = issamples(x,test1,test2,...) 0009 % 0010 % x parameter to test 0011 % test1... optional list of additional tests (see examples below) 0012 % 0013 % EXAMPLES 0014 % 0015 % % Test if x is a list of samples 0016 % issamples(x) 0017 % 0018 % % Special test: test if x is a point process (i.e. 1 column) 0019 % issamples(x,'#0') 0020 % 0021 % % Special test: test if x contains 3 variables (i.e. 4 columns) 0022 % issamples(x,'#3') 0023 % 0024 % SEE ALSO 0025 % 0026 % See also isdmatrix, isdvector, isdscalar, isimatrix, isivector, isiscalar, 0027 % isastring, islscalar, islvector, islmatrix. 0028 % 0029 0030 % Copyright (C) 2010-2012 by Michaƫl Zugaro 0031 % 0032 % This program is free software; you can redistribute it and/or modify 0033 % it under the terms of the GNU General Public License as published by 0034 % the Free Software Foundation; either version 3 of the License, or 0035 % (at your option) any later version. 0036 0037 function test = issamples(x,varargin) 0038 0039 % Check number of parameters 0040 if nargin < 1, 0041 error('Incorrect number of parameters (type ''help <a href="matlab:help issamples">issamples</a>'' for details).'); 0042 end 0043 0044 % Test: double, vector or matrix 0045 test = isdvector(x) | isdmatrix(x); 0046 test = test & isdvector(x(:,1),'<'); 0047 0048 % Optional tests 0049 for i = 1:length(varargin), 0050 try 0051 if varargin{i}(1) == '#', 0052 if size(x,2)-1 ~= str2num(varargin{i}(2:end)), test = false; return; end 0053 end 0054 catch err 0055 error(['Incorrect test ''' varargin{i} ''' (type ''help <a href="matlab:help issamples">issamples</a>'' for details).']); 0056 end 0057 end