Simulink SImulation Inputs and Model Variables

5 visualizaciones (últimos 30 días)
Florian Rössing
Florian Rössing el 16 de En. de 2023
Comentada: Paul el 22 de En. de 2023
I want to run a model for different input parameters, using an arraySimulink.SimulaitonInput Objects.
In the StopFcn of the Model I want to read some of the model parameters and variables set by the simulink.SimulationInput objects.
To access the parameters I can call
get_param(gcs,'Parameter')
to get the value of the parameter as set by the Simulink.SimulationInput object.
However to access variables of the model I would need to do:
mdlWks = get_param(gcs,'ModelWorkspace');
Variable = getVariable(mdlWks,'Variable');
This however only gives me the default version of the value for Variable. I waat the current set value of Variable though. Is there an alternative get_var function or something that can do this?

Respuesta aceptada

Paul
Paul el 16 de En. de 2023
Instead of using the StopFcn, maybe you can use setPostSimFcn functionality
  7 comentarios
Paul
Paul el 19 de En. de 2023
Well, you could just as easily do that. But the original qeustion started with using using the StopFcn, so I thought you wanted to use automatic callback functionality. Either way, sounds like you have a path forward.
Paul
Paul el 22 de En. de 2023
I just realized that the code I posted will overwrite output data in output of sim. The corrections would be pass the sim output into the post sim function, modify it, and return it.
simIn(ii) = setPostSimFcn(simIn(ii),@(simout) simpostfunc(out,simIn(ii).Variables));
function out = simpostfunc(out,simvariables)
% simple function to echo the simIn variables to the the simulation output
out.simvars = simvariables;
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Configure and View Diagnostics en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by