Simulink SImulation Inputs and Model Variables

5 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Paul
Paul il 16 Gen 2023
Instead of using the StopFcn, maybe you can use setPostSimFcn functionality
  7 Commenti
Paul
Paul il 19 Gen 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 il 22 Gen 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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Configure and View Diagnostics in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by