Home > FMAToolbox > Helpers > isstring.m

isstring

PURPOSE ^

isstring - Test if parameter is an (admissible) character string.

SYNOPSIS ^

function test = isstring(x,varargin)

DESCRIPTION ^

isstring - Test if parameter is an (admissible) character string.

  USAGE

    test = isstring(x,string1,string2,...)

    x              item to test
    string1...     optional list of admissible strings

  SEE ALSO

    See also isdmatrix, isdvector, isdscalar, isimatrix, isivector, isiscalar.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %isstring - Test if parameter is an (admissible) character string.
0002 %
0003 %  USAGE
0004 %
0005 %    test = isstring(x,string1,string2,...)
0006 %
0007 %    x              item to test
0008 %    string1...     optional list of admissible strings
0009 %
0010 %  SEE ALSO
0011 %
0012 %    See also isdmatrix, isdvector, isdscalar, isimatrix, isivector, isiscalar.
0013 %
0014 
0015 % Copyright (C) 2004-2010 by Michaƫl Zugaro
0016 %
0017 % This program is free software; you can redistribute it and/or modify
0018 % it under the terms of the GNU General Public License as published by
0019 % the Free Software Foundation; either version 3 of the License, or
0020 % (at your option) any later version.
0021 
0022 function test = isstring(x,varargin)
0023 
0024 % Check number of parameters
0025 if nargin < 1,
0026   error('Incorrect number of parameters (type ''help <a href="matlab:help isstring">isstring</a>'' for details).');
0027 end
0028 
0029 test = true;
0030 
0031 if ~ischar(x),
0032     test = false;
0033     return;
0034 end
0035 
0036 if isempty(varargin), return; end
0037 
0038 for i = 1:length(varargin),
0039     if strcmp(x,varargin{i}), return; end
0040 end
0041 
0042 test = false;

Generated on Tue 13-Mar-2012 09:42:06 by m2html © 2005