Clear Filters
Clear Filters

Setting variable values in workspace for simulating model in command window.

2 views (last 30 days)
1. Ineed to know the variable names used in the model(.mdl) file using command. 2. If i know the variable names used in the model, then how to set the variable values in the workspace so that the sim() method is used to simulate the model.
3. How to get the output of the simulation.
Please help.

Answers (1)

Kaustubha Govind
Kaustubha Govind on 7 Jul 2011
Once you have found all the variables needed by the model, you can use the assignin command to create the variable in the base workspace. When you run the SIM command, it looks for the variables in the base workspace by default. Note that any logged signals will also be created in the base-workspace by default.
Alternatively, if you'd like the model to look for and log the variables in the workspace of the function that you are calling SIM from (without littering the base workspace), you can use the SrcWorkspace and DstWorkspace options (as described here).
See Single-Output Syntax for the sim Command for help on getting all the outputs packed into a single structure.

Categories

Find more on Event Functions in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!