islscalar - Test if parameter is a (pseudo) logical scalar. USAGE test = islscalar(x) x parameter to test NOTE To be considered logical, the scalar should be equal to 0 or 1, but it does not need to actually be of class 'logical' (class(x) could be e.g. 'double'). SEE ALSO See also islvector, islmatrix, isdmatrix, isdvector, isdscalar, isimatrix, isivector, isastring.
0001 %islscalar - Test if parameter is a (pseudo) logical scalar. 0002 % 0003 % USAGE 0004 % 0005 % test = islscalar(x) 0006 % 0007 % x parameter to test 0008 % 0009 % NOTE 0010 % 0011 % To be considered logical, the scalar should be equal to 0 or 1, but it does 0012 % not need to actually be of class 'logical' (class(x) could be e.g. 'double'). 0013 % 0014 % SEE ALSO 0015 % 0016 % See also islvector, islmatrix, isdmatrix, isdvector, isdscalar, isimatrix, isivector, 0017 % isastring. 0018 % 0019 0020 % Copyright (C) 2010-2011 by Michaƫl Zugaro 0021 % 0022 % This program is free software; you can redistribute it and/or modify 0023 % it under the terms of the GNU General Public License as published by 0024 % the Free Software Foundation; either version 3 of the License, or 0025 % (at your option) any later version. 0026 0027 function test = islscalar(x) 0028 0029 % Check number of parameters 0030 if nargin < 1, 0031 error('Incorrect number of parameters (type ''help <a href="matlab:help islscalar">islscalar</a>'' for details).'); 0032 end 0033 0034 % Test: double, scalar 0035 test = islogical(x) & isscalar(x); 0036 0037 0038 function test = islogical(x) 0039 0040 test = builtin('islogical',x) | all(x(:)==0|x(:)==1);