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
댓글 수: 0
답변(1개)
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
참고 항목
범주
Find more on Perform Sensitivity Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!