Error using vertcat ; Dimensions of arrays being concatenated are not consistent.

1 Ansicht (letzte 30 Tage)
I am trying to use the following code for solving a system of 3 ode. I am getting error which running this code.
beta = 0.1;
delta = 0.05;
max_time = 100;
S0 = 0.95;
I0 = 0.05;
R0 = 0.0;
dXdt = @(t,X) [ -beta*X(1)*X(2); beta*X(1)*X(2) -delta*X(2); delta*X(2)];
[t,X] = ode45(dXdt, [0 max_time],[S0 I0 R0]);
figure
plot(t,X)

Antworten (1)

Chunru
Chunru am 11 Sep. 2022
beta = 0.1;
delta = 0.05;
max_time = 100;
S0 = 0.95;
I0 = 0.05;
R0 = 0.0;
dXdt = @(t,X) [ -beta*X(1)*X(2); beta*X(1)*X(2)-delta*X(2); delta*X(2)];
% ^ No space here
[t,X] = ode45(dXdt, [0 max_time],[S0 I0 R0]);
figure
plot(t,X)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by