plotting the solutions of a differential system with numerical ways
3 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Mischa Kim
on 6 May 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
More Answers (1)
Azzi Abdelmalek
on 6 May 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)
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!