Clear Filters
Clear Filters

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

1 view (last 30 days)
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)

Answers (1)

Chunru
Chunru on 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)

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!