How to run a simulink model using a program? what is the command used?

Sim command is generally used....I am confused how it is used....how the values produced from the program are transfered to the simulink model.

 采纳的回答

sim('YourModel');
OR
set_param('YourModel', 'SimulationCommand', 'start');
Using set_param('YourModel', 'SimulationCommand', ...) you can start, stop, pause or continue the simulation.

3 个评论

Thank you so much for this answer.....
Suppose we are try to link an optimisation program with a model....ie. we are trying to pass the values from the program to the model....how is it done?
set_param('newmodel/PID','KP','10');This command shows no error....
but
set_param('newmodel/PID','KP','a'); this command shows the error...
where a = arr(1,1); arr() is an arg of the function
Error in 'newmodel/PID': Parameter 'KP' cannot be evaluated. MATLAB error message: Undefined function or variable 'KP'
Please help...
"where a = arr(1,1); arr() is an arg of the function"
Didn't understand - arr() is an arg of the function.
for "set_param('newmodel/PID','KP','a')" a should be present on base workspace.
You need to set the SrcWorkspace parameter as described here: http://www.mathworks.com/matlabcentral/answers/10149-simulink-workspace
By default, Simulink looks for the parameter variables in the base workspace. Setting SrcWorkspace to 'current' forces it to use the current (function) workspace instead.

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 DSP Algorithm Acceleration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by