What blocks are supported for changing parameters with parsim command?

6 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Julia Antoniou
Julia Antoniou am 25 Okt. 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 Kommentare
Antonio Carlo Bertolino
Antonio Carlo Bertolino am 27 Okt. 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 am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Run Multiple Simulations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by