Documentation

datefind

Indices of date numbers in matrix

Syntax

Indices = datefind(Subset, Superset, Tolerance)

Arguments

Subset

Subset matrix of date numbers used to find matching date numbers in Superset. These date numbers, specified as serial date numbers or datetime arrays, must be a nonrepeating subset of those in Superset.

Superset

Superset matrix of nonrepeating date numbers, specified as serial date numbers or datetime arrays, whose elements are sought.

Tolerance

(Optional) Tolerance (+/-) for matching the date numbers in Superset. A positive integer. Default = 0.

Description

Indices = datefind(Subset, Superset, Tolerance) returns a vector of indices to the date numbers in Superset that are present in Subset, plus or minus the Tolerance. If no date numbers match, Indices = [].

Although this function was designed for use with sequential date numbers, you can use it with any nonrepeating integers.

Subset and Superset can be either serial date numbers or datetime arrays. There types do not have to match. datefind will determine the underlying date in order to match dates of different data types. Tolerance can be expressed as either a double or a duration.

Examples

collapse all

Return a Vector of Indices to Date Numbers

This example shows how to return a vector of indices to date numbers.

Superset = datenum(1999, 7, 1:31);
Subset = [datenum(1999, 7, 10); datenum(1999, 7, 20)];
Indices = datefind(Subset, Superset, 1)
Indices =

     9
    10
    11
    19
    20
    21

Related Examples

See Also

|

Introduced before R2006a

Was this topic helpful?