The values in a
datetime array represent points in time using the
proleptic ISO calendar.
When you use
datetime arrays with code generation, adhere to these
For code generation, use the
datetime function to create
datetime 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 a
datetime array from these input arrays.
function d = foo(y,mo,d,h,mi,s) %#codegen d = datetime(y,mo,d,h,mi,s); end
For code generation, you are restricted to the operations on
arrays listed in this table.
d = datetime(2019,1:12,1,12,0,0); d(1) = datetime(2019,1,31);
Code generation does not support using the assignment operator
d = datetime(2019,1:12,1,12,0,0); tf = d(1) < d(2);
Code generation supports relational operators.
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.
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
For code generation, you can use
datetime arrays with these
MATLAB toolbox functions: