Assign variable values using model workspace, symbols, data objects, and data classes

You can use MATLAB® variables to configure and manage the signals and block parameters in your model. For more information about how models use variables, see Symbol Resolution.

In addition to numeric variables, you can use data objects to parameterize a model. Data objects allow you to control many attributes of model signals and parameters, such as data types and code generation settings, by adjusting the properties of variables in a workspace. For more information, see Data Objects.

You can store model variables in the MATLAB base workspace, a model workspace, or a data dictionary.

All model files have a model workspace you can use to store variables. For more information, see Model Workspaces.

You can create separate data dictionary files to store model variables. You can add and remove data dictionaries to and from models, reference the contents of a dictionary in other dictionaries, and track changes to a dictionary. For more information, see What Is a Data Dictionary?


getVariable Get value of variable from workspace
hasVariable Determine if variable exists in workspace
Simulink.findVars Find variables in models and blocks Save workspace variables to MATLAB script
set_param Set system and block parameter values
get_param Get parameter names and values Create new data dictionary and create object Open data dictionary for editing Evaluate MATLAB expression in context of Simulink model Modify variable values in context of Simulink model Check existence of variable in context of Simulink model Restore defaults after parallel simulation with data dictionary Enable parallel simulation with data dictionary


Simulink.ModelWorkspace Describe model workspace
Simulink.WorkspaceVar Contains information about workspace variables and blocks that use them
Simulink.VariableUsage Get information about workspace variables and blocks that use them Configure data dictionary Configure data dictionary section Configure data dictionary entry Store enumerated type definition in data dictionary
Was this topic helpful?