I did a couple experiments. You can use a value from the terminal as a constant in xcos without any complex steps, you just execute the code that declares that variable in the terminal and you can use it in xcos.
For example, I write a = 10
in the terminal, and xcos recognizes that name as valid when you write it in a block. When you start the simulation xcos copies it’s value and it turns into a constant, so changing it’s value in the terminal, for example a=5
during the simulation does nothing, it will remain as 10 until the simulation ends.
If you use that same name a
in the context box of the simulation, the simulation will use that value instead of the one you have in the terminal.
So yeah, you can have variables in the terminal that you change before each simulation using the sliders and the simulation will use their values everywhere that you wrote them. You could even make the parameters a list that you unpack inside the context manager, for example:
simulation_parameters = tlist(["params", "T_reg", "T_Pon", "K_p", "K_i", "DT", "T_p", "R_r", "R_f", "L_m"], [],[],[],[],[],[],[],[],[]);
Have the gui modify params
’s values and inside the xcos context box write:
[T_reg, T_Pon, K_p, K_i, DT, T_p, R_r, R_f, L_m] = simulation_parameters(:)
This way you can have only 1 variable name ocuppied in the terminal.
Edit: sorry for going on a bit of a tangent at the end, it annoys me to occupy too much namespace in a program when it isn’t needed.