how to re-assign parameter value assigned in an active variant in SimBiology?

조회 수: 2(최근 30일)
Hi, I cannot re-assign a value to a parameter, kdeg, defined in the active variant, variant1.
The following code shows the steps I performed (sbproj file attached)
% model
projectVersion = "variantTest.sbproj";
s = sbioloadproject(projectVersion);
modelObj = s.m1; % MAIN
% kdeg = 1 value is shown while the active variant value is 0.3:
componentObj = sbioselect(modelObj,'Name','kdeg','Type','parameter')
% an re-assignment is futile although it shows in 'modelObj.Parameters' below
if numel(componentObj) ~= 1
disp('error');
else
set(componentObj,'Value',3)
end
modelObj.Parameters
% 'kdeg' is listed showing new value, 3, but the active variant
% value is stil 0.3 as the plot shows
% deactivating does not work:
% % variantObj.Active = false
% % modelObj.Parameters
simDataObj = sbiosimulate(modelObj);
simDataObj = selectbyname(simDataObj,'Species1');
sbioplot(simDataObj); grid on;
The question is how to re-assign, overwrite the variant value, and 'activate' a new value of 'kdeg'?
I have tried to inactivate the variant but that without success.
Any hints would be very appreciated! M

답변(1개)

Arthur Goldsipe
Arthur Goldsipe 2022년 10월 18일
편집: Arthur Goldsipe 2022년 10월 18일
sbiosimulate(modelObj) will simulate using only active variants. If you set all your variants to inactive, then you should simulate the model with the appropriate parameter value of 3. It it possible you're setting Active to false on the wrong variant?
Alternatively, you can ignore the active property and explicitly specify the variants and/or doses you want to simulate with as follows:
sbiosimulate(modelObj, []); % default configset; active variants, active doses
sbiosimulate(modelObj, [],[]) % default configset; no variants; active doses
sbiosimulate(modelObj, [],[],[]) % default configset; no variants; no doses
I added the following lines to the end of your script and confirmed things work as expected (namely that kdeg is 3 during the simulation):
allVariants = getvariant(modelObj);
set(allVariants, 'Active', false);
cs = getconfigset(modelObj, 'active');
% Explicitly log kdeg during simulations
cs.RuntimeOptions.StatesToLog(end+1) = componentObj;
simDataObj2 = sbiosimulate(modelObj)
simDataObj2b = selectbyname(simDataObj2,'kdeg');
simDataObj2b.Data
  댓글 수: 5
emjey
emjey 2022년 10월 25일
편집: emjey 2022년 10월 27일
Thanks Artur for clarifying, 'commit' was indeed what I was after!
Btw, unfortunately, I will not attend ACoP.

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

범주

Find more on Perform Sensitivity Analysis in Help Center and File Exchange

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by