I will elaborate with more elements that I gathered from the documentation:
This thread is telling me that if there is a conflict between a variable from the Model workspace and a variable in a SimulationInput instance, it needs to be dealt with:
However, the variable has to exist in the Model workspace to be used (and modified) as part of the simulation, including in a compiled model, see this example, which explicitly states "External input variables must be in the MATLAB workspace before packaging for deployment." :
From now on, I fail to understand the correct way modify a variable in the model workspace. On top of this, there are limitations around rapid accelerated models, which is the case for me, since I am trying to compile a model into a shared library. These limitations are the following:
"If a block parameter value references workspace variables, you cannot change the block parameter value during rapid accelerator simulation, such as by using the function set_param. Instead, you can tune the values of the referenced variables."
set_param is not compatible with MATLAB Compiler, which is why I resort to SimulationInput.setVariable. But I do not understand what I am doing wrong here, or what I am supposed to do differently. I am trying to change the values of my variables before launching the simulation with sim, not during the simulation.