What blocks are supported for changing parameters with parsim command?
6 views (last 30 days)
Show older comments
Antonio Carlo Bertolino
on 20 Oct 2017
Commented: Rahul Kumar
on 29 Aug 2018
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 Comments
Accepted Answer
Julia Antoniou
on 25 Oct 2017
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 Comments
Rahul Kumar
on 29 Aug 2018
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.
More Answers (0)
See Also
Categories
Find more on Run Multiple Simulations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!