Main Content

Define Duration Array Inputs

You can define duration array inputs at the command line. Programmatic specification of duration input types by using preconditioning (assert statements) is not supported.

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);
fiaccel myFunction -args {D}

Provide a Duration Array Type

To provide a type for a duration array to fiaccel:

  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 fiaccel by using the -args option.

    fiaccel 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);
fiaccel myFunction -args {coder.Constant(C)}

Representation of Duration Arrays

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

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 = 

   matlab.coder.type.DurationType
     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 (MATLAB Coder).

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 = 

   matlab.coder.type.DurationType
     1x3 duration
	Format : 1x10 char

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

See Also

| (MATLAB Coder) | (MATLAB Coder)

Related Topics