datefind
Indices of dates in matrix
Description
Examples
Return a Vector of Indices to Date Numbers
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
Subset
— Subset of dates to find matching dates
datetime array | string array | date character vector
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
— Superset of dates
datetime array | string array | date character vector
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
— Tolerance for matching dates in Superset
0
(default) | positive integer or duration object
Tolerance for matching dates (+/-
) in Superset
,
specified as a positive integer or duration object.
Data Types: single
| double
Output Arguments
Version History
Introduced before R2006aR2022b: Serial date numbers not recommended
Although datefind
supports serial date numbers,
datetime
values are recommended instead. The
datetime
data type provides flexible date and time
formats, storage out to nanosecond precision, and properties to account for time
zones and daylight saving time.
To convert serial date numbers or text to datetime
values, use the datetime
function. For example:
t = datetime(738427.656845093,"ConvertFrom","datenum"); y = year(t)
y = 2021
There are no plans to remove support for serial date number inputs.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)