How to resolve "too many input arguments"-error using the sim command

14 Ansichten (letzte 30 Tage)
I'm running a simulink-model in rapid accelerator mode.
Some key information are:
I load a whole data set into my matlab workspace before running the simulation in acceleration mode for the first time, because without it, it won't run the simulation.
I want to modify quite a few parameters when the model is already compiled so I use "setVariable" method for all these parameters before starting the simulation.
This is essentialy what is done before running the simulation. These are method from a corresponding class. There is a Parameter script being run, where all the parameters are being saved to a file, this file in turn is used to set all the Simulink model variables.
function out = runSimulation(obj)
obj.saveParamsToFile();
simIn = Simulink.SimulationInput(obj.simModelName);
simIn = obj.assignVarsFromFileToModelWsp(simIn, obj.simDataFile);
simIn = simIn.setModelParameter('StopTime', num2str(obj.fahrmanoeverObj.t_sim));
simulink.compiler.configureForDeployment(simIn);
simIn = simIn.setModelParameter("SimulationMode", "Rapid", "RapidAcceleratorUpToDateCheck", "off");
obj.simOutput = sim(simIn);
out = obj.simOutput;
end
function newSimIn = assignVarsFromFileToModelWsp(obj, simIn, file)
load(file);
myvars = who;
for i = 1:length(myvars)
avar = myvars(i);
value = eval(avar{:});
simIn = simIn.setVariable(avar{:}, value);
end
newSimIn = simIn;
end
At "obj.simOutput = sim(simIn)" I get the error: "Too many input arguments."
Indeed if I reduce the number of arguments it will run.The compiled model just uses it's at-compile-time and not-up-to-date parameters to run the simulation, which is not what I want.
I wanted to check if all the parameters really are tunable in simulink, but there are so many blocks, I'd rather know if this can really be the cause of error.
I can't send the model I'm using but I attached a zip file, that contains a reduced model that also raises this error and a script "test_sim.m".
You'll need to load the data file "mydata.mat" before you run this script for the first time, because the accelerator expects all the variables to be initialized in the workspace. After that you should get the same error as I do.
This is not exactly the same setup, that I use, but the same error ocurrs so maybe you can give me some Insight in what is going wrong.

Antworten (1)

Shree Charan M L
Shree Charan M L am 9 Okt. 2023
Bearbeitet: Shree Charan M L am 19 Okt. 2023
Hi Christopher,
The error seems to occur because “RapidAcceleratorUpToDateCheck” is set to ‘off’.
simIn = setModelParameter(simIn,"RapidAcceleratorUpToDateCheck","off")
disables rebuilding the rapid accelerator target. You may refer to https://www.mathworks.com/help/simulink/slref/simulink.simulationinput.setmodelparameter.html#mw_0af4648c-c899-464e-8da1-83bbeea1162e for more info on the same.
When new variables are set, there is a mismatch in the arguments passed and the arguments expected by the rapid accelerator target which causes the error ‘too many input arguments’.
Rebuilding the rapid accelerator target would update the input tuneable parameters configuration of the rapid accelerator target.

Kategorien

Mehr zu Acceleration 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