What blocks are supported for changing parameters with parsim command?

5 views (last 30 days)
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

Accepted Answer

Julia Antoniou
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
Antonio Carlo Bertolino
Antonio Carlo Bertolino on 27 Oct 2017
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 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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!