Main Content

Specify Properties of Entry-Point Function Inputs

Why You Must Specify Input Properties

Fixed-Point Designer™ must determine the properties of all variables in the MATLAB® files at compile time. To infer variable properties in MATLAB files, Fixed-Point Designer must be able to identify the properties of the inputs to the primary function, also known as the top-level or entry-point function. Therefore, if your primary function has inputs, you must specify the properties of these inputs, to Fixed-Point Designer. If your primary function has no input parameters, Fixed-Point Designer can compile your MATLAB file without modification. You do not need to specify properties of inputs to local functions or external functions called by the primary function.

Note

Your primary function cannot be within a MATLAB namespace. Create a wrapper function as the primary function outside the namespace. Call the desired function within the new function as the primary function.

Methods of Input-Type Specification

MethodAdvantagesDisadvantages

Define Input Properties at the Command Line

Note

You cannot use this method if you define input properties by using assert statements in your MATLAB code

  • Easy to use

  • Does not alter original MATLAB code

  • Designed for prototyping a function that has few primary inputs

  • Must be specified at the command line every time you generate code (unless you use a script)

  • Not efficient for specifying memory-intensive inputs such as large structures and arrays

Specify Input Types Using assert Statements in MATLAB Code

  • Integrated with MATLAB code

  • Documents argument specifications in the MATLAB entry-point function

  • Efficient for specifying memory-intensive inputs such as large structures

  • Uses complex syntax

  • Project files do not currently recognize properties defined programmatically. If you are using a project, you must reenter the input types in the project.

Properties to Specify

If your primary function has inputs, you must specify the following properties for each input.

ForSpecify properties
 ClassSizeComplexitynumerictypefimath
Fixed-point inputs

Check mark

Check mark

Check mark

Check mark

Check mark

Each field in a structure input

 Specify properties for each field according to its class

Other inputs

Check mark

Check mark

Check mark

  

Default Property Values

Fixed-Point Designer assigns the following default values for properties of primary function inputs.

PropertyDefault
classdouble
sizescalar
complexityreal
numerictypeNo default
fimathMATLAB default fimath object

Supported Classes

The following table presents the class names supported by Fixed-Point Designer.

Class NameDescription
logicalLogical array of true and false values
charCharacter array
int88-bit signed integer array
uint88-bit unsigned integer array
int1616-bit signed integer array
uint1616-bit unsigned integer array
int3232-bit signed integer array
uint3232-bit unsigned integer array
int6464-bit signed integer array
uint6464–bit unsigned integer array
singleSingle-precision floating-point or fixed-point number array
doubleDouble-precision floating-point or fixed-point number array
structStructure array
embedded.fiFixed-point number array

Rules for Specifying Properties of Primary Inputs

When specifying the properties of primary inputs, follow these rules:

  • The order of elements in the cell array must correspond to the order in which inputs appear in the primary function signature. For example, the first element in the cell array defines the properties of the first primary function input.

  • To generate fewer arguments than those arguments that occur in the MATLAB function, specify properties for only the number of arguments that you want in the generated function.

  • If the MATLAB function has input arguments, to generate a function that has no input arguments, pass an empty cell array to -args.

  • For each primary function input whose class is fixed point (fi), specify the input numerictype and fimath properties.

  • For each primary function input whose class is struct, specify the properties of each of its fields in the order that they appear in the structure definition.

  • If you generate a MEX, SIL, or PIL function that accepts an empty array with a given shape, the generated function accepts empty arrays of other shapes as well. The MEX, SIL, or PIL function reshapes the empty run-time input array to match the shape of the array that was specified at code generation time.