Wrapping function/model into a gui for easy interaction: No clue how to start anything

1 view (last 30 days)
I am stuck with a task I am an absolute newbie at, and that I really don't understand.
We have two SIR-epidemiology models, one of which is posted below. One uses the euler-method for calculating, the other does it normally.
We are supposed to make the models interactive by embedding them into a gui which needs to:
  1. have editable start-values, with a default start value already entered in case the user doesn't change it (S0 I0 R0, tmax)
  2. have sliders for manipulating the different parameters (b and k)
  3. plot the model
  4. respond to changes in slider-vales (b and k) with updating the model accordingly, then updating the plot
Aaaand... I have a wide range of non-knowledge in this topic. So I have quite literally no idea where to properly start, or do any of that.
I've had a rather shitty week of everything not going to plan, and now I have a deadline on sunday and am at pants-on-head levels of clueless right now. That's why I am a bit frantic about this right now.
Thank you.
Claudius Appel
%% SIR using Euler
% Time range:
tmax = 500;
% Initial values for S, I and R: %% needs to be editable as
% start-vals
S0 = 1;
I0 = 1.27e-6;
R0 = 0;
% Birth rate and death rate parameters: %% needs to be editable as
% start-vals
b = 1/2;
k = 1/3;
% Predict population dynamics for SIR model with Euler's method:
%% this should then update every x seconds or so, while responding to current input
[S, I, R] = SIRmodel(tmax, S0, I0, R0, b, k)
Plot S, I and R vs time:
plot(0:tmax, S, 'b')
hold on
plot(0:tmax, I, 'r')
plot(0:tmax, R, 'g')
title('SIR Model')
legend('S(t)', 'I(t)', 'R(t)')
xlabel('Time, t')
% xlim([0, 40])
hold off
% This function defines S(t), I(t) and R(t) with the Euler's method.
function [S,I,R] = SIRmodel(tmax, S0, I0, R0, b, k)
S = zeros(1, tmax);
I = zeros(1, tmax);
R = zeros(1, tmax);
S(1) = S0;
I(1) = I0;
R(1) = R0;
T(1) = 0;
Delta_t = 1;
for n = 1:tmax
T(n+1) = T(n) + Delta_t;
S(n+1) = S(n) - b * S(n) * I(n) * Delta_t;
I(n+1) = I(n) + (b * S(n) *I(n) - k * I(n)) * Delta_t;
R(n+1) = R(n) + k * I(n) * Delta_t;

Answers (0)


Find more on General Applications 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!