Formatting for 'addobservables'
9 views (last 30 days)
Show older comments
Shaun Tan on 11 Nov 2021
Commented: Shaun Tan on 19 Nov 2021
I've built a SIR epidemic model on SimBiology and want to calculate its sobol indices.
I have 2 parameters, alpha and gamma, which describe infection rate and recovery rate, and 3 species, 'S', 'I' and 'R' to represent the population compartments.
I want to determine peak infections after the simulation (what is the highest value for the 'I' species) and set that as the observable which I will the input into the sbiosobol function to determine effect of alpha and gamma on the value of peak infections.
This is the code:
r1=addrule(m1,'S = -beta*S*I/N','RuleType','rate');
r2=addrule(m1,'I = beta*S*I/N-gamma*I','RuleType','rate');
r3=addrule(m1,'R = gamma*I','RuleType','rate');
However, I am getting an error for the imax=... line which reads: "Name 'pop' in observable 'imax' does not uniquely refer to any species, parameters, compartments, or observables according to SimBiology precedence rules."
Florian Augustin on 11 Nov 2021
expressions of SimBiology observables can only reference names of components on the model, or functions on the Matlab path; referencing variables in the Matlab Workspace is not supported.
If I understand you use case correctly, you can reference "I" instead of "pop(:,2)" in the observable's expression:
addobservable(m1, "imax", "max(I)"); % <- reference I here instead of pops(:,2).
% Run Sobol analysis:
sobolResults = sbiosobol(m1, ["beta", "gamma"], "imax", "ShowWaitbar", true);
% Plot results:
I hope this helps.
More Answers (0)
More Answers in the SimBiology Community
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!