ODE45: Check for missing argument or incorrect argument | Error in odearguments (line 90) & ode45 (line 115)

1 view (last 30 days)
Hello,
I searched this forum and others for an solution but didnt find any that helped me.
I get the Following Errorcodes:
Check for missing argument or incorrect argument data type in call to function 'SIR_DGLSystem'.
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 SIRDModell/Solve_DGL (line 61)
[obj.t, obj.SIR] = ode45(@SIR_DGLSystem, [obj.t0, obj.tF], [obj.N, obj.S, obj.I, obj.R], [], [obj.beta, obj.gamma, obj.mu, obj.v]);
My Code is a class, wich I broke into pieces to analyse it better. You first type x = SIRDModell() then Solve_DGL(x). hen the Errorcode comes up.
I'm really clueless on this one!
classdef SIRDModell
properties
S
I
R
D
t0
tF
t % Zeitvektor
gamma
mu
k % Kappa Kontaktrate
Lamda % Übertragungswahrscheinlichkeit
beta
v
T % Transmissionskoeffizient b/N
N
end
methods
function obj = SIRDModell()
%Werte über die Bevölkerung
obj.N = 1000; %Population
obj.I = 3; %Infizierte
obj.R = 0; %Genese
obj.D = 0; %Gestorbene
obj.S = obj.N - obj.I - obj.R - obj.D; %nicht Infizerte
%Werte über die Krankeheit
obj.beta = 0.4; %Infektionsrate
obj.gamma = 0.4;%Sterbe oder genese Rate
obj.mu = 0.04; %allgemeine Sterberate
obj.v = 0.05; %Geburtenrate
obj.T = obj.beta./obj.N; %Transmissionsrate
obj.Lamda = (obj.beta .* obj.I) ./ obj.N ; %Infektionsrate
%Zeitraum
obj.t0 = 0; %Startzeit
obj.tF = 100; %Endzeit
%obj.dt = 1; %Zeititterationne
end
function obj = Solve_DGL(obj)
% ODEFUn TSPAN y0 Options par
[obj.t, obj.SIR] = ode45(@SIR_DGLSystem, [obj.t0, obj.tF], [obj.N, obj.S, obj.I, obj.R], [], [obj.beta, obj.gamma, obj.mu, obj.v]);
end
function dSIR_dt = SIR_DGLSystem(t, SIRD, par)
%SIRD(1) = N; SIRD(2) = S; SIRD(3) = I; SIRD(4) = R
%par(1) = beta, par(2) = gamma, par(3) = mu, par(4) = v
dSIR_dt(1,1) = par(4)*SIRD(1) -(par(1)*SIRD(2)*SIRD(3)) ./SIRD(1) - par(3)*SIRD(2);
dSIR_dt(2,1) = (par(1)*SIRD(2)*SIRD(3))./SIRD(1) - par(2)*SIRD(3) - par(3)*SIRD(3);
dSIR_dt(3,1) = par(2)*SIRD(3) - par(3)*SIRD(4);
dSIR_dt(4,1) = par(3).*SIRD(3);
end
end
end
  2 Comments
Torsten
Torsten on 29 May 2021
I don't know if this is the reason for the error message: You supply four initial conditions to ode45, but only solve for three unknowns.
Lennart Gravert
Lennart Gravert on 29 May 2021
the same Error comes up, when I put the 4th Equation back it. I just commended it out to test something.

Sign in to comment.

Accepted Answer

Cris LaPierre
Cris LaPierre on 29 May 2021
If I remove the class structure and just run this as a script, I get a different error. Perhaps investigating this one will fix the error your class is giving you. Perhaps try different initial conditions, or check that your equations are properly defined.
%Werte über die Bevölkerung
obj.N = 1000; %Population
obj.I = 3; %Infizierte
obj.R = 0; %Genese
obj.D = 0; %Gestorbene
obj.S = obj.N - obj.I - obj.R - obj.D; %nicht Infizerte
%Werte über die Krankeheit
obj.beta = 0.4; %Infektionsrate
obj.gamma = 0.4;%Sterbe oder genese Rate
obj.mu = 0.04; %allgemeine Sterberate
obj.v = 0.05; %Geburtenrate
obj.T = obj.beta./obj.N; %Transmissionsrate
obj.Lamda = (obj.beta .* obj.I) ./ obj.N ; %Infektionsrate
%Zeitraum
obj.t0 = 0; %Startzeit
obj.tF = 100; %Endzeit
%obj.dt = 1; %Zeititterationne
% ODEFUn TSPAN y0 Options par
[obj.t, obj.SIR] = ode45(@SIR_DGLSystem, [obj.t0, obj.tF], [obj.N, obj.S, obj.I, obj.R], [], [obj.beta, obj.gamma, obj.mu, obj.v]);
Warning: Failure at t=1.336027e+01. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (2.842171e-14) at time t.
function dSIR_dt = SIR_DGLSystem(t, SIRD, par)
%SIRD(1) = N; SIRD(2) = S; SIRD(3) = I; SIRD(4) = R
%par(1) = beta, par(2) = gamma, par(3) = mu, par(4) = v
dSIR_dt(1,1) = par(4)*SIRD(1) -(par(1)*SIRD(2)*SIRD(3)) ./SIRD(1) - par(3)*SIRD(2);
dSIR_dt(2,1) = (par(1)*SIRD(2)*SIRD(3))./SIRD(1) - par(2)*SIRD(3) - par(3)*SIRD(3);
dSIR_dt(3,1) = par(2)*SIRD(3) - par(3)*SIRD(4);
dSIR_dt(4,1) = par(3).*SIRD(3);
end

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!