Main Content

ismissing

(Not Recommended) Find dataset array elements with missing values

The dataset data type is not recommended. To work with heterogeneous data, use the MATLAB® table data type instead. See MATLAB table documentation for more information.

Description

I = ismissing(ds) returns a logical array that indicates which elements in the dataset array, ds, contain a missing value. By default, ismissing recognizes NaN as a missing value in numeric variables, '' as a missing value in character variables, and <undefined> as a missing value in categorical arrays.

  • ds2 = ds(~any(I,2),:) creates a new dataset array containing only the complete observations in ds.

  • ds2 = ds(:,~any(I,1)) creates a new dataset array containing only the variables from ds with no missing values.

I = ismissing(ds,Name=Value) returns missing value indices with additional options specified by one or more Name=Value arguments.

Input Arguments

collapse all

Dataset array, specified as a dataset object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: ix = ismissing(messyData,NumericTreatAsMissing=-99)

Numeric missing value indicators, specified as a vector of numeric values in floating-point ds variables. ismissing always treats a NaN value as a missing value.

String missing value indicators, specified as a character vector, string array, or cell array of character vectors to treat as missing value indicators in character ds variables. ismissing always treats '' as a missing value.

Output Arguments

collapse all

Indicator for elements containing missing values, returned as a logical array. This array indicates which elements in ds contain a missing value. I is the same size as ds, with value 1 for elements that contain a missing value.

Version History

Introduced in R2012b