Code Generation for Datetime Arrays
The values in adatetime
array represent points in time using the proleptic ISO calendar.
When you usedatetime
arrays with code generation, adhere to these restrictions.
Define Datetime Arrays for Code Generation
For code generation, use thedatetime
function to createdatetime
arrays. For example, suppose the input arguments to your MATLAB®function are numeric arrays whose values indicate the year, month, day, hour, minute, and second components for a point in time. You can create adatetime
array from these input arrays.
functiond = foo(y,mo,d,h,mi,s)%#codegend = datetime(y,mo,d,h,mi,s);end
Allowed Operations on Datetime Arrays
For code generation, you are restricted to the operations ondatetime
arrays listed in this table.
Operation | Example | Notes |
---|---|---|
Assignment operator: |
d = datetime(2019,1:12,1,12,0,0); d(1) = datetime(2019,1,31); |
不支持使用assignm生成代码金宝appent operator
|
Relational operators: |
d = datetime(2019,1:12,1,12,0,0); tf = d(1) < d(2); |
Code generation supports relational operators. |
Indexing operation |
d = datetime(2019,1:12,1,12,0,0); idx = [1 2]; d(idx); idx = logical([1 1 0]); d(idx); |
Code generation supports indexing by position, linear indexing, and logical indexing. |
Concatenation |
d1 = datetime(2019,1:6,1,12,0,0); d2 = datetime(2019,7:12,1,12,0,0); d = [d1 d2]; |
Code generation supports concatenation of |
MATLABToolbox Functions That Support Datetime Arrays
For code generation, you can usedatetime
arrays with these MATLAB toolbox functions: