
How do I solve this differential system by using ode45?
3 views (last 30 days)
Show older comments
Here is my system. how do i use ode45 to solve this. I dont know how to build a array contain all these funciton and put into ode45.
Thank for helping me.
x' = 6*x/y;
y' = x'*4;
z' = 16*x';
x0 %Initial condition are known,
y0
z0
0 Comments
Answers (1)
Sam Chak
on 27 Mar 2022
Hi @Gan Huang
Since
is known, you can make direct substitutions into
and
. Here is the demo:
function Demo_ode45
close all
clc
tspan = [0 1]; % time span of simulation
y0 = [1 0.5 0.25]; % initial values
[t, y] = ode45(@(t, y) odefcn(t, y), tspan, y0);
plot(t, y, 'linewidth', 1.5)
grid on
xlabel('Time, t [sec]')
ylabel('x, y, z')
title('Time responses of the system')
legend('x', 'y', 'z', 'location', 'best')
end
function dydt = odefcn(t, y) % Ordinary Differenctial Equations
dydt = zeros(3,1);
dydt(1) = 6*y(1)/y(2);
dydt(2) = 4*(6*y(1)/y(2));
dydt(3) = 16*(6*y(1)/y(2));
end
Result:

0 Comments
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!