Main Content

Define Duration Array Inputs

You can define duration array inputs at the command line or in the MATLAB® Coder™ app. Code generation does not support the programmatic specification of duration input types by using function argument validation (arguments blocks) or by using preconditioning (assert statements).

Define Duration Array Inputs at the Command Line

Use one of these procedures:

Alternatively, if you have a test file that calls your entry-point function with example inputs, you can determine the input types by using coder.getArgTypes.

Provide an Example Duration Array Input

Use the -args option:

D = duration(1:3,0,0);
codegen myFunction -args {D}

Provide a Duration Array Type

To provide a type for a duration array to codegen:

  1. Define a duration array. For example:

    D = duration(1:3,0,0);

  2. Create a type from D.

    t = coder.typeof(D);

  3. Pass the type to codegen by using the -args option.

    codegen myFunction -args {t}

Provide a Constant Duration Array Input

To specify that a duration array input is constant, use coder.Constant with the -args option:

D = duration(1:3,0,0);
codegen myFunction -args {coder.Constant(C)}

Define Duration Array Inputs in the MATLAB Coder App

Use one of these procedures:

Representation of Duration Arrays

A coder type object for a duration array describes the object and its properties. Use coder.typeof or pass duration as a string scalar to coder.newtype.

The coder type object displays a succinct description of the object properties while excluding internal state values. Nonconstant properties display their type and size, while constant properties display only their values. For example:

tType = coder.newtype('duration')

A representation of an empty duration variable is stored in coder type object tType.

tType = 

     1x1 duration
	Format : 1x8 char

If your workflow requires the legacy representation of coder type objects, use the getCoderType function on the variable that has the new representation of your class or object. See Legacy Representation of Coder Type Objects.

Resize duration Properties by Editing Object Properties

You can resize most objects by editing the object properties. You can resize duration objects, its properties and create arrays within the properties.

For a duration coder object, you can resize the object properties:

t = duration((1:3),0,0);
tType = coder.typeof(t)
tType.Format = 'DD/MM/YYYY'

This code resizes the Format property to be a 1x10 char property.

tType = 

     1x3 duration
	Format : 1x10 char

You can also resize the object by using coder.resize. See Edit and Represent Coder Type Objects and Properties.

See Also

| |

Related Topics