plotting the solutions of a differential system with numerical ways
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Mischa Kim
le 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
Plus de réponses (1)
Azzi Abdelmalek
le 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)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!