
How do I solve this differential system by using ode45?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Sam Chak
am 27 Mär. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!