# datefind

Indices of dates in matrix

## Description

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

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

## Examples

collapse all

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

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

9
10
11
19
20
21

## Input Arguments

collapse all

Subset of dates to find matching dates in Superset, specified as a matrix using a datetime array, string array, or date character vectors.

Subset and Superset can be either be a datetime array, string array, or date character vectors. These types do not have to match. datefind determines the underlying date to match dates of different data types.

Note

The elements of Subset must be contained in Superset, without repetition. datefind works with non-repeating sequences of dates.

Example: Subset = [datetime(1997,7,10); datetime(1997,7,20)];

To support existing code, datefind also accepts serial date numbers as inputs, but they are not recommended.

Data Types: char | string | datetime

Superset of dates, specified as a matrix of using a datetime array, string array, or date character vectors, whose elements are sought.

Subset and Superset can be either a datetime array, string array, or date character vectors. These types do not have to match. datefind determines the underlying date to match dates of different data types.

Note

The elements of Subset must be contained in Superset, without repetition. datefind works with non-repeating sequences of dates.

Example: Superset = datetime(1997,7,1:31);

To support existing code, datefind also accepts serial date numbers as inputs, but they are not recommended.

Data Types: char | string | datetime

Tolerance for matching dates (+/-) in Superset, specified as a positive integer or duration object.

Data Types: single | double

## Output Arguments

collapse all

Indices of dates in Superset that are present in Subset (plus or minus the tolerance if defined using the optional argument Tolerance), returned as a vector of indices.

## Version History

Introduced before R2006a

expand all