Input Type Specification for Code Generation - MATLAB & Simulink (original) (raw)

C/C++ and MATLAB® handle variables differently. Some of these differences that affect the code generation workflow are:

To allow the generation of C/C++ code with specific types, you must specify the properties (class, size, and complexity) of all input variables to the MATLAB entry-point functions during C/C++ or MEX code generation. An_entry-point function_ is a top-level MATLAB function from which you generate code. The code generator uses these input properties to determine the properties of all variables in the generated code. Different input type specifications can cause the same MATLAB code to produce different versions of the generated code.

You can specify input types:

To see how input type specification affects the generated code, consider a simple MATLAB function myMultiply that multiplies two quantitiesa and b and returns the value of the product.

function y = myMultiply(a,b) y = a*b; end

Generate static C library code for three different type specifications for the input arguments a and b. In each case, inspect the generated code.

The arguments a_data, b_data, andy_data correspond to the input argumentsa and b and the output argumenty in the original MATLAB function. The C function now accepts three additional arguments,a_size, b_size, andy_size, that specify the sizes ofa_data, b_data, andy_data at run time.

See Also

codegen | coder.typeof