Home > FMAToolbox > Helpers > isastring.m

isastring

PURPOSE ^

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

SYNOPSIS ^

function test = isastring(x,varargin)

DESCRIPTION ^

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

  USAGE

    test = isastring(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 %isastring - Test if parameter is an (admissible) character string.
0002 %
0003 %  USAGE
0004 %
0005 %    test = isastring(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-2016 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 = isastring(x,varargin)
0023 
0024 % Check number of parameters
0025 if nargin < 1,
0026   error('Incorrect number of parameters (type ''help <a href="matlab:help isastring">isastring</a>'' for details).');
0027 end
0028 
0029 test = true;
0030 
0031 if ~isvector(x),
0032     test = false;
0033     return;
0034 end
0035 if ~ischar(x),
0036     test = false;
0037     return;
0038 end
0039 
0040 if isempty(varargin), return; end
0041 
0042 for i = 1:length(varargin),
0043     if strcmp(x,varargin{i}), return; end
0044 end
0045 
0046 test = false;

Generated on Fri 16-Mar-2018 13:00:20 by m2html © 2005