C Data and Function Interfaces - MATLAB & Simulink (original ) (raw )Map model data elements and functions to model-independent code definitions
To comply with code standards and guidelines, integrate generated code with external code, and address memory requirements, configure the representation of model data elements and entry-point functions for code generation. You configure model data elements and functions by mapping them to code definitions that are predefined by the product or created with the Embedded Coder Dictionary. For data elements, you also have the option of mapping them to code definitions created in packages with the Custom Storage Class Designer.
For an introduction, see C Data Code Interface Configuration for Model Interface Elements .
Objects Functionsexpand all
model_initialize
Generated C/C++ entry-point function that contains initialization code for aSimulink model
model_reset
Generated C/C++ entry-point function that contains reset code for a Simulink model
model_step
Generated C/C++ entry-point function that contains execution code for each step in aSimulink model
model_terminate
Generated C/C++ entry-point function that contains termination code for aSimulink model
Create and Find Code Mappings
coder.mapping.api.get
Get code mappings for model (Since R2020b)
coder.mapping.utils.create
Create code mappings object for configuring data and function interface for C and C++ code generation (Since R2020b)
find
Get model elements for the category of model code mappings (Since R2020b)
Default Configurations
getDataDefault
Get default storage class or storage class property setting for model data category (Since R2020b)
getFunctionDefault
Get default function customization template or memory section for model functions category (Since R2020b)
setDataDefault
Set default storage class and storage class property values for model data category (Since R2020b)
setFunctionDefault
Set default function customization template and memory section for model functions category (Since R2020b)
Function Configuration
getFunction
Get code configuration from code mappings for model function (Since R2020b)
setFunction
Set coder mapping information for model function (Since R2020b)
Root-Level Inport and Outport Configuration
getInport
Get code and calibration configuration from code mappings for root-level inport (Since R2020b)
getOutport
Get code and calibration configuration from code mappings for root-level outport (Since R2020b)
getDeploymentType
Get deployment type of model (Since R2022a)
setInport
Configure root-level inports for code and calibration file (a2l) generation (Since R2020b)
setOutport
Configure root-level outport for code and calibration file (a2l) generation (Since R2020b)
setDeploymentType
Set deployment type of model (Since R2022a)
Parameter Configuration
getModelParameter
Get code and calibration configuration from code mappings for model parameters (Since R2020b)
getModelVariantControl
Get code configuration from code mappings forSimulink.VariantControl object (Since R2025a)
getModelVariantVariable
Get code configuration from code mappings forSimulink.VariantVariable object (Since R2025a)
setModelParameter
Configure model parameter for code and calibration file (a2l) generation (Since R2020b)
setModelVariantControl
Configure Simulink.VariantControl object for code generation (Since R2025a)
Signal, State, and Data Store Configuration
addSignal
Add block output signal to model code mappings (Since R2020b)
getDataStore
Get code and calibration configuration from code mappings for local or shared local data store (Since R2020b)
getSignal
Get code and calibration configuration from code mappings for block output signal (Since R2020b)
getState
Get code and calibration configuration from code mappings for block state (Since R2020b)
removeSignal
Remove block output signal from model code mappings (Since R2020b)
setDataStore
Configure local or shared local data store for code and calibration file (a2l) generation (Since R2020b)
setSignal
Configure block signal data for code and calibration file (a2l) generation (Since R2020b)
setState
Configure block states for code and calibration file (a2l) generation (Since R2020b)
Coder Dictionary Configuration
setDataDefault
Set default code settings for data category (Since R2021a)
getDataDefault
Get default code settings for data category (Since R2021a)
setFunctionDefault
Set default function customization template and memory section for model functions category (Since R2021a)
getFunctionDefault
Get default function customization template or memory section for model functions category (Since R2021a)
Topics Configuration Fundamentals
C Data Configuration
C Function Configuration
Data Access and Initialization
Create Tunable Calibration Parameter in the Generated Code In the generated code, create tunable parameter data that you can access during rapid prototyping and calibration.
Reuse Parameter Data in Different Data Type Contexts Reuse parameter data by creating a Simulink.Parameter
object or numeric MATLABĀ® variable that you can use in different data type contexts.
Limitations for Block Parameter Tunability in Generated Code Limitations can prevent a block parameter from appearing in the generated code as tunable, which means you cannot interact with the parameter value after compiling the code.
Access Signal, State, and Parameter Data During Execution As you iteratively develop a model, capture output signal and state data that model execution generates. Tune parameter values during execution to observe results on the outputs.
Switch Between Sets of Parameter Values During Simulation and Code Execution Switch between independent sets of values for the same block parameters by storing the sets in an array of structures.
Preserve Variables in Generated Code As you iteratively develop a model, you can tune block parameter values during simulation or execution of generated code to observe the results on signal and state values.
Configure Packaging of Parameter Arguments in Generated Code Customize the implementation of parameter arguments in generated code.
Control Signal and State Initialization in the Generated Code Generate code that enables you to store tunable initial conditions in memory, for example, for modeling a system that shuts down and restarts.
Initialization of Signal, State, and Parameter Data in the Generated Code To match the numerics of a simulation in Simulink, the generated code assigns initial values to global data, especially for block states and parameters.
Compile Code Conditionally for All Values of Variant Parameters with Same and Different Dimensions This example shows how to generate a C code that contains all the active and inactive values of variant parameters.
Featured Examples