How can I plot the graph of three non-linear coupled ODE's vs. time in xy-plane in MATLAB. I want to use x-axis for time while y axis for x(1),x(2),x(3) thanks
1 view (last 30 days)
Show older comments
My ODE's are:
k_1*x(2)-k1*x(1)-k3*x(1)*x(2)+k_3*x(3);
k1*x(1)-(k_1+k2)*x(2)-k3*x(1)*x(2)+(k4+k_3)*x(3);
k3*x(1)*x(2)-(k4+k_3)*x(3)
where parameter values are as given below
k1 = 1.5;
k_1 = 0.5;
k2 = 1;
k3 = 2;
k_3 = 1;
k4 = 3;
0 Comments
Accepted Answer
Walter Roberson
on 8 Dec 2021
tspan = [0 10];
x0 = [0 0.1 0.2];
[t, x] = ode45(@odefun, tspan, x0);
plot(t, x);
legend({'x(1)', 'x(2)', 'x(3)'}, 'location', 'best');
function dk = odefun(t, x)
k1 = 1.5;
k_1 = 0.5;
k2 = 1;
k3 = 2;
k_3 = 1;
k4 = 3;
dk = [k_1*x(2)-k1*x(1)-k3*x(1)*x(2)+k_3*x(3);
k1*x(1)-(k_1+k2)*x(2)-k3*x(1)*x(2)+(k4+k_3)*x(3);
k3*x(1)*x(2)-(k4+k_3)*x(3) ];
end
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!