I have a simple transfer function model with with a single variable input (Gain, referred to as 'k'). I am trying to run 10 simulations with the value of 'k' starting at 1 and increasing by a value of 1 with each iteration. The first way I tried to do this was following a tutorial with the following code:
for k = 1:10;
data(k) = sim ('model_name', 'ReturnWorkspaceOutputs', 'on');
end
This ended up giving me 1x10 simulation output matrix with the same output data (as if k had a value of 5 each time). If I run the sim once with k = 1 the output is still as if k had a value of 5. The model-sim works as expected when launched from simulink (not launched from matlab). I then tried creating 10 input class objects using the following code as per the documentation on Simulink input class with the following code.
for l = 1:10;
in = Simulink.SimulationInput('model_name');
in = in.setBlockParameter('k', 'Value', 'l');
data(l) = sim ('in', 'ReturnWorkspaceOutputs', 'on');
end
The error I am getting here is "Undefined variable "Simulink" or class "Simulink.SimulationInput"". My question is this, what is the best (simple) way to run simulations iteratively while changing block parameters with each consecutive iteration? Thank you for your time.