table.ismissing
table: TF = ismissing (tbl)
table: TF = ismissing (tbl, indicator)
table: TF = ismissing (…, 'OutputFormat', outFmt)
Find missing values in table.
TF = ismissing (tbl) returns a logical array,
TF, with any true values corresponding to missing elements
in the input table tbl.
Missing values are defined according to the data type of each variable in tbl:
NaN - double, single, duration and calendarDuration
NaT - datetime
<missing> - string
<undefined> - categorical
{''} - cell arrays of character vectors
'' - character arrays
TF = ismissing (tbl, indicator) also returns a
logical array, TF, with any true values corresponding to
elements in the input table tbl, which are equal to the values in
indicator. When specifying an indicator, all default missing
values are ignored. If you want to keep them, you need to define them in
indicator.
indicator can be either a vector of specific data type, in which case all other data types in table tbl are ignored, or a cell array containing mixed types of data types, in which case they match the data types of the variables in table tbl. Missing values specified by indicator also apply to nested tables.
Besides the explicit data type match between indicator and tbl, the following additional data types matches apply.
double indicators match numeric and logical variables.
logical indicators match numeric and logical variables.
char and cellstr indicators match string variables.
char and string indicators match categorical
variables.
The output array TF has the same size as the input table tbl.
TF = ismissing (…, specifies whether TF is returned as a logical array
or as a table, which maintains the variable names and all other
information of the input table tbl. Specifying outFmt as
'OutputFormat',
outFmt)'logical' (default) returns a logical array. Specifying
outFmt as 'tabular' returns a table.
Source Code: table
Where anymissing gives a single yes/no, ismissing locates every gap, returning a logical array the size of the table — one flag per element. It recognises the missing value proper to each type at once.
Name = string ({'Li'; 'Diaz'; 'Brown'});
Age = [38; NaN; 40];
Grade = categorical ({'A'; 'B'; ''});
Visit = datetime (2024, 1, [5; NaN; 7]);
T = table (Name, Age, Grade, Visit)
T =
3x4 table
Name Age Grade Visit
_______ ___ ___________ ___________
"Li" 38 A 05-Jan-2024
"Diaz" NaN B NaT
"Brown" 40 <undefined> 07-Jan-2024
ismissing (T)
ans = 0 0 0 0 0 1 0 1 0 0 1 0
Pass an indicator to also treat specific sentinel values as missing.
ismissing (table ([1; -99; 3]), -99)
ans = 0 1 0