How do I change these commands to plot different differential equations?
Show older comments
I have found a video on youtube which does the following code to solve a pair of differential equations:
mu =
300
200
>> eta = [400 100]'
eta =
400
100
>> F=@(t,y) [(1-y(2)/mu(2))*y(1); -(1-y(1)/mu(1))*y(2)]
F =
function_handle with value:
@(t,y)[(1-y(2)/mu(2))*y(1);-(1-y(1)/mu(1))*y(2)]
>> ode45(F,[0 25],eta)
ode45(F,[0 25],eta]
If i have dx/dt = 1.5x - 0.7xy
and dy/dt = 7x - 20.7xy
What should i do to solve these two equations if the initial x and y values are 2.6 and 6 respectively?
Thanks!
I should be getting something similar to this:

Answers (1)
madhan ravi
on 9 Dec 2018
Edited: madhan ravi
on 9 Dec 2018
EDITED
mu=[300
200];
eta = [400 100]';
F=@(t,y) [(1-y(2)/mu(2))*y(1); -(1-y(1)/mu(1))*y(2)]
[t,y]=ode45(F,[0 25],eta) % you forgot to give outputs
plot(t,y(:,1),'-ob',t,y(:,2),'-or')

9 Comments
AFHG
on 9 Dec 2018
madhan ravi
on 9 Dec 2018
"If i have dx/dt = 1.5x - 0.7xy
and dy/dt = 7x - 20.7xy
What should i do to solve these two equations if the initial x and y values are 2.6 and 6 respectively?"
Dont bring up additional questions I solved for the above question!
madhan ravi
on 9 Dec 2018
Can't you solve it in the same way , I showed you? Read the documentation page to get familiar with ode solvers.
AFHG
on 9 Dec 2018
madhan ravi
on 9 Dec 2018
see edited answer
AFHG
on 9 Dec 2018
madhan ravi
on 9 Dec 2018
ah.... which values?? then paramterize your function
Categories
Find more on Programming 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!
