TheGalax
TheGalax

Reputation: 71

Modeling SIR model in matlab and simulink

I am trying to model a SIR epidemic model in matlab and simulink. I think I've already done it in matlab but for some reason my simulink model won't work. It just shows straight lines in a scope. This is my function to calculate differential equations.

function dx = sir(t, x)
  dx = [0; 0; 0];
  beta = .5; 
  delta = .3;
    dx(1) = -beta * x(1) * x(2);
    dx(2) = beta * x(1) * x(2) - delta * x(2);
    dx(3) = delta * x(2);
  end

This is my workspace code to show plot enter image description here and this is mu simulink with yields this strange plot and this is after autoscaling with initial conditions set to S = 7900000 and R = 0 and I = 10 enter image description here

Upvotes: 1

Views: 2733

Answers (1)

Phil Goddard
Phil Goddard

Reputation: 10762

The List of Signals property of the summation block that is being fed by the Product3 and Product2 blocks should be |+- instead of |--.

Upvotes: 2

Related Questions