gusucode.com > datatypes 工具箱matlab源码程序 > datatypes/+matlab/+internal/+tableUtils/hasMissingVal.m

    function tf = hasMissingVal(v)
%HASMISSINGVAL Identify rows of an array that have missing values.
%    TF = hasMissingVal(X) returns a logical vector with one value per row
%    of X, indicating whether any value in that row is missing.  Missing
%    value indicators are NaN for floating point types, "<undefined>" for
%    categorical types, empty '' for cell arrays of character vectors,
%    <missing> for string arrays, NaT for datetimes, NaN for durations, or
%    entirely blank for character arrays.

%   Copyright 2013-2016 The MathWorks, Inc.

v = v(:,:);

if isfloat(v)
    tf = any(isnan(v),2);
elseif iscategorical(v)
    tf = any(isundefined(v),2);
elseif iscellstr(v)
    tf = any(cellfun('isempty',v),2);
elseif ischar(v)
    tf = all(v == ' ',2);
elseif isdatetime(v)
    tf = any(isnat(v),2);
elseif isduration(v)
    tf = any(isnan(v),2);
elseif isa(v, 'string')
    tf = any(ismissing(v), 2);
else % including integers
    tf = false(size(v,1),1);
end