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

1 次查看(过去 30 天)
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)

回答(1 个)

Chunru
Chunru 2022-9-11
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)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by