What blocks are supported for changing parameters with parsim command?

6 次查看(过去 30 天)
Hello, I'm running my model in a parallel pool using parsim command. I realized that one of the parameter that I would like to tune and change from one simulation to the following one is a parameter which arises in the model inside a Fcn block: in the simulation results I figured out that nothing happened when that parameter has changed. Is there a solution to make also this parameter inside a Fcn block changing? What blocks allows the variables inside them to be tunable?
Thanks in advance, Antonio

采纳的回答

Julia Antoniou
Julia Antoniou 2017-10-25
Hi Antonio,
I would recommend using the example on the documentation page for the "parsim" function, linked below. https://www.mathworks.com/help/simulink/slref/parsim.html
This example demonstrates how to change a variable used in a Simulink model named "cstr" using the "Simulink.SimulationInput" class and the "setVariable" method.
I was not able to use a variable name in the code of a MATLAB function block and then change that variable value over multiple simulations using the above method. However, you could work around this issue by creating an extra input to your MATLAB function block, and wiring a constant block to this input. Make the value of the constant block the name of the variable you would like to change, such as "Parameter". You can then use the "setVariable" method with "Parameter" to change the value during each simulation.
  2 个评论
Antonio Carlo Bertolino
Hi Julia, thanks a lot for your answer! I've found the same solution in the previous days and when I've read your answer I understood that this is the method to overcome the issue with the tunable variables inside Fcn blocks. Thanks again.
Rahul Kumar
Rahul Kumar 2018-8-29
I just wanted to add that the 'Value' of a Constant block can also be changed using setBlockParameter method on SimulationInput without having to define a variable, for example,
in = in.setBlockParameter('path/to/the/constant/block', 'Value', '15')
Please note the quotes around the specified value which are required since block parameter values are character vectors.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Run Multiple Simulations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by