I try to evaluate a simulink model in matlab. Therefor I use the matlab command sim(...). I found this two pages with some information:
and also some entries on stackoverlow. But there I found only partial solutions to my problem and combining them did not work.
Here a minimal example of my problem:
The simulink model has a single input parameter which is plugged directly to a output parameter. THe input parameter is called input, the output parameter is called output. This model is named 'minimal'. For simplicity this is all.
My matlab script looks like the following:
slCharacterEncoding('Windows-1252');
input = 1;
mdl = 'minimal';
simMode = get_param(mdl, 'SimulationMode');
cs = getActiveConfigSet(mdl);
mdl_cs = cs.copy;
set_param(mdl_cs,'AbsTol','1e-5',...
'SaveState','on','StateSaveName','xoutNew',...
'SaveOutput','on','OutputSaveName','youtNew')
evalin('base','input=1');
options=simset('SrcWorkspace','base','DstWorkspace','base');
sim(mdl,[0 1],options)
disp(yout);
disp('Simulation ended.');
As value after each simulation step I only receive 0. The input parameter is clearly not set.
What I would like to have, is a way to set the input parameter and receive and print the output parameter to the console.
It would be even better, when I can set an array of input parameters and with each simulation step the inputs are set to the corresponding value.