Main Content

simulink.multisim.Variable

Specify a range of values for model variables

Since R2024a

Description

The simulink.multisim.DesignStudy object represents a design study that allows you to run multiple simulations at a large scale. With the simulink.multisim.Variable object, you can specify variables and their values for massive simulations using parameter combinations.

Creation

Description

simVars = simulink.multisim.Variable(varname,varvalue) sets the value of the variable varname to the value varvalue for the simulation configured using the simulink.multisim.Variable object. Use this syntax to specify values for variables in the base workspace or data dictionaries. The variable values you specify override the variable values saved in the base workspace or data dictionary during simulation and are reverted when the simulation completes.

You can specify values for multiple variables on a simulink.multisim.Variable object. Specify the value for each variable one at a time.

simVars = simulink.multisim.Variable(varname,varvalue,Workspace=mdl) sets the value of the variable varname in the model workspace of the model mdl.

By default, when you do not specify the Workspace argument, variables are scoped to a global workspace specific to each object. Variables in the global workspace override variables with the same name in the base workspace and in data dictionaries but not in the model workspace.

Input Arguments

expand all

Variable name, specified as a string or a character vector.

Variable value, specified as a MATLAB expression.

Model workspace in which to specify variable value, specified as a string or a character vector.

Example: simVars = simulink.multisim.Variable("k",10,Workspace="MyModel") sets the value of the variable k in the model workspace of the model named MyModel to 10.

Output Arguments

expand all

Specified simulation variables with values, returned as a simulink.multisim.Variable object.

Properties

expand all

Name of the variable for the simulation, returned as a string or a character vector.

Variable value, specified as a MATLAB expression.

Workspace in which to specify variable value, returned as a string or a character vector.

Function handle to process the specified values that run on parallel workers, specified as a function handle or function name. The ProcessingFcn property allows you to perform additional processing on the variable values before the simulation. You can use the ProcessingFcn property to transform the values assigned to the simulink.multisim.Variable object per your requirements. For example, you can use the function to transform a string values of a variable to a timeseries value.

The example shows how to use the ProcessingFcn property to perform additional operations on the variables. To use the ProcessingFcn property, all the files that the function uses must be on the parallel workers.

myModel = 'ex_sldemo_suspn_2dof';
inputs = simulink.multisim.Variable("input ds", ["Road1, "Road2", "Road4"]);
inputs.ProcessingFcn = @(x) myProcessingFcn(x, 'signalData.mat');

% ProcessingFcn
function input_ds = myProcessingFcn(inputName,matFileName)
    disp('Running myProcessingFcn')
    S = load(matFileName,inputName)
    input_ds = S.(inputName)
end

Version History

Introduced in R2024a