Help CenterHelp Center
Load variables from MAT-file into a Simulink.SimulationInput object, in
Simulink.SimulationInput
in
in = in.loadVariablesFromMATFile('filename')
example
in = in.loadVariablesFromMATFile('filename') loads variables from the specified MAT-file into the Variables property of Simulink.SimulationInput.
filename
Variables
collapse all
This example shows how to load variables from MAT-File into Simulink.SimulationInput object using the loadVariablesFromMATFile method.
Create a Simulink.SimulationInput Object
Create a Simulink.SimulationInput object for the example model.
mdl = 'ex_loadVar_sldemo_househeat'; in = Simulink.SimulationInput(mdl); in
in = SimulationInput with properties: ModelName: 'ex_loadVar_sldemo_househeat' InitialState: [0x0 Simulink.op.ModelOperatingPoint] ExternalInput: [] ModelParameters: [0x0 Simulink.Simulation.ModelParameter] BlockParameters: [0x0 Simulink.Simulation.BlockParameter] Variables: [0x0 Simulink.Simulation.Variable] PreSimFcn: [] PostSimFcn: [] UserString: ''
Load Variables From MAT-File
Use the loadVariablesFromMATFile method of the Simulink.SimulationInput object.
in = in.loadVariablesFromMATFile('sldemo_househeat_data.mat'); in
in = SimulationInput with properties: ModelName: 'ex_loadVar_sldemo_househeat' InitialState: [0x0 Simulink.op.ModelOperatingPoint] ExternalInput: [] ModelParameters: [0x0 Simulink.Simulation.ModelParameter] BlockParameters: [0x0 Simulink.Simulation.BlockParameter] Variables: [1x25 Simulink.Simulation.Variable] PreSimFcn: [] PostSimFcn: [] UserString: ''
Simulate the Model
The model uses the loaded variables for simulation
out = sim(in)
out = Simulink.SimulationOutput: sldemo_househeat_output: [1x1 Simulink.SimulationData.Dataset] SimulationMetadata: [1x1 Simulink.SimulationMetadata] ErrorMessage: [0x0 char]
Name of MAT-file, specified as a character vector or string scalar.
Example: 'myFile'
'myFile'
Simulink.SimulationInput | parsim | applyToModel | setBlockParameter | setModelParameter | setInitialState | setExternalInput | setVariable | setPreSimFcn | setPostSimFcn | Simulation Manager
parsim
applyToModel
setBlockParameter
setModelParameter
setInitialState
setExternalInput
setVariable
setPreSimFcn
setPostSimFcn
Simulation Manager
You have a modified version of this example. Do you want to open this example with your edits?
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office