Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Fill missing values

`F = fillmissing(A,'constant',v)`

`F = fillmissing(A,method)`

`F = fillmissing(A,movmethod,window)`

`F = fillmissing(___,dim)`

`F = fillmissing(___,Name,Value)`

```
[F,TF] =
fillmissing(___)
```

fills
missing entries of an array or table with the constant value `F`

= fillmissing(`A`

,'constant',`v`

)`v`

.
If `A`

is a matrix or multidimensional array, then `v`

can
be either a scalar or a vector. When `v`

is a vector,
each element specifies the fill value in the corresponding column
of `A`

. If `A`

is a table or timetable,
then `v`

can also be a cell array.

Missing values are defined according to the data type of `A`

:

`NaN`

—`double`

,`single`

,`duration`

, and`calendarDuration`

`NaT`

—`datetime`

`<missing>`

—`string`

`<undefined>`

—`categorical`

`' '`

—`char`

`{''}`

—`cell`

of character arrays

If `A`

is a table, then the data type of each
column defines the missing value for that column.

fills
missing entries using the method specified by `F`

= fillmissing(`A`

,`method`

)`method`

,
which can be one of the following:

`'previous'`

— previous non-missing value`'next'`

— next non-missing value`'nearest'`

— nearest non-missing value`'linear'`

— linear interpolation of neighboring, non-missing values (numeric,`duration`

, and`datetime`

data types only)`'spline'`

— piecewise cubic spline interpolation (numeric,`duration`

, and`datetime`

data types only)`'pchip'`

— shape-preserving piecewise cubic spline interpolation (numeric,`duration`

, and`datetime`

data types only)

specifies
additional parameters for filling missing values using one or more
name-value pair arguments. For example, if `F`

= fillmissing(___,`Name,Value`

)`t`

is
a vector of time values, then `fillmissing(A,'linear','SamplePoints',t)`

interpolates
the data in `A`

relative to the times in `t`

.

Was this topic helpful?