How to solve problems with ODE in my SIR model?
Afficher commentaires plus anciens
clc; close all; clear
b = 0.5; % probability of contracting the disease
y = ode45("epidemia", [0 60], [495; 5; 0]);
N = x(1) + x(2) + x(3); % a fixed population for 500 individuals
g = 0.15; % recovery rate
xdot(1) = - b*x(2)*x(1)/N; % Susceptible differential equation
xdot(2) = b*x(2)*x(1)/N - g*x(2); % Infectious differential equation
xdot(3) = g*x(2); % Recovered differential equation
%x0 = [495; 5; 0]; % Initial 495 Susceptible and 5 Infectious
%t = linspace(0, 60, 600); % 60-week duration (600 data points)
plot(t, y);
legend ('Susceptible', 'Infectious', 'Recovered');
function xdot = epidemia(x, t)
xdot = zeros(3, 1);
end
Errors:
Error using feval
Unrecognized function or variable 'epidemia'.
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in Untitled4 (line 4)
y = ode45("epidemia", [0 60], [495; 5; 0]);
Untitled4 it's a name of my script.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!