isrealvarname.m

来自「toolbox of BVQX, This is the access betw」· M 代码 · 共 39 行

M
39
字号
function retval = isrealvarname(testname)
%ISREALVARNAME True for valid variable name.
%   ISREALVARNAME(S) is true if S is a valid MATLAB variable name.
%   A valid variable name is a character string of letters, digits and
%   underscores, with length <= namelengthmax and the first character a letter.
%
%   See also ISKEYWORD, ISVARNAME, NAMELENGTHMAX.
%
%   Revised, since the Windows version returns true for INVALID names!

% Version:  v0.6e
% Build:    7041710
% Date:     Apr-17 2007, 10:02 AM CEST
% Author:   Jochen Weber, Brain Innovation, B.V., Maastricht, NL
% URL/Info: http://wiki.brainvoyager.com/BVQXtools

% argument check
if nargin < 1
    error( ...
        'BVQXtools:TooFewArguments',...
        'Too few arguments. Try ''help %s''.',...
        mfilename ...
    );
end

% test only valid char inputs
if ischar(testname) && ...
   ~isempty(testname) && ...
    numel(testname) == size(testname, 2) && ...
    all(double(testname) < 123 & double(testname) > 47) && ...
    testname(1) > 64 && ...
   (testname(1) < 90 || ...
    testname(1) > 96) && ...
    isempty(intersect(testname, char([58:64, 91:94, 96])));
    retval = true;
else
    retval = false;
end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?