Simulink SImulation Inputs and Model Variables

조회 수: 5 (최근 30일)
Florian Rössing
Florian Rössing 2023년 1월 16일
댓글: Paul 2023년 1월 22일
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?

채택된 답변

Paul
Paul 2023년 1월 16일
Instead of using the StopFcn, maybe you can use setPostSimFcn functionality
  댓글 수: 7
Paul
Paul 2023년 1월 19일
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 2023년 1월 22일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Configure and View Diagnostics에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by