Hi, I'm quite new to MATLAB and recently tried to plot a SIR model using its first order equations, but everytime I tried to use the ODE45 it the equation doesn't seem to change it just gives me a constant plot of the initial value. Can anyone spot a problem? Code is below:
clear all, close all, clcA = 0.1;B = 0.3;tspan = [0:0.01:300];y0 = [300 0 0];[t,y] = ode45(@(t,y)odefcn(y,A,B),tspan,y0);plot(t,y)function dydt = odefcn(y,A,B)dydt = zeros(3,1);dydt(1) = -A*y(2)*y(1);dydt(2) = A*y(2)*y(1)-B*y(2);dydt(3) = B*y(2);end
Best Answer