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
0 个评论
采纳的回答
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 个评论
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 Center 和 File Exchange 中查找有关 Run Multiple Simulations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!