Main Content

Automatically Define Input Types by Using the App

Because C and C++ use static typing, the MATLAB® Coder™ app must determine the properties of all variables in the MATLAB files at compile time. Therefore, you must specify the properties of all entry-point function inputs. From the properties of the entry-point function inputs, MATLAB Coder can infer the properties of all variables in the MATLAB files.

If you specify a test file that calls the project entry-point functions, the MATLAB Coder app can infer the input argument types by running the test file. If a test file calls an entry-point function multiple times with different size inputs, the app takes the union of the inputs. The app infers that the inputs are variable size, with an upper bound equal to the size of the largest input.

Before using the app to automatically define function input argument types, you must add at least one entry-point file to your project. You must also specify code that calls your entry-point functions with the expected input types. It is a best practice to provide a test file that calls your entry-point functions. The test file can be either a MATLAB function or a script. The test file must call the entry-point function at least once.

To automatically define input types:

  1. On the Define Input Types page, specify a test file. Alternatively, you can enter code directly.

  2. Click Autodefine Input Types.

    The app runs the test file and infers the types for entry-point input arguments. The app displays the inferred types.

If you must run more that one test file to define all input types, repeat this procedure for each test file.

Note

If you automatically define the input types, the entry-point functions must be in a writable folder.

If your test file does not call an entry-point function with different size inputs, the resulting type dimensions are fixed-size. After you define the input types, you can specify and apply rules for making type dimensions variable-size when they meet a size threshold. See Make Dimensions Variable-Size When They Meet Size Threshold.

The MATLAB Coder app is not supported in MATLAB Online™.