plotting the solutions of a differential system with numerical ways
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, i'm trying to plot the solutions of a differential system with a numerical method, i don't know how to do this, does anyone know how to do in matlab with an example ?
This is my system:
dx/dt=((3x+2)/(5y+x)) +3*x dy/dt=3*x*y-5y
Thanks you very much !!!
0 Kommentare
Akzeptierte Antwort
Mischa Kim
am 6 Mai 2015
Yep, take a look:
function my_EOM()
IC = [-1 -1];
[t,qsol] = ode45(@EOM,[0 1],IC);
plot(t,qsol)
xlabel('t')
ylabel('x, y')
grid
end
function dqdt = EOM(~,q)
x = q(1);
y = q(2);
dqdt = [((3*x + 2)/(5*y + x)) + 3*x; ...
3*x*y - 5*y];
end
Weitere Antworten (1)
Azzi Abdelmalek
am 6 Mai 2015
start_time=0
final_time=10
in=[1 ;0]; %initials conditions
[t,y] = ode45(@myfcn,[start_time final_time],in);
plot(t,y)
Where myfcn is a function
function dy=myfcn(t,y)
dy=zeros(2,1)
dy(1)=(3*y(1)+2)/(5*y(2)+y(1))+3*y(1)
dy(2)=3*y(1)*y(2)-5*y(1)
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!