How do I change these commands to plot different differential equations?
Mostrar comentarios más antiguos
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:

1 comentario
AFHG
el 9 de Dic. de 2018
Respuestas (1)
madhan ravi
el 9 de Dic. de 2018
Editada: madhan ravi
el 9 de Dic. de 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 comentarios
AFHG
el 9 de Dic. de 2018
madhan ravi
el 9 de Dic. de 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
el 9 de Dic. de 2018
Can't you solve it in the same way , I showed you? Read the documentation page to get familiar with ode solvers.
AFHG
el 9 de Dic. de 2018
madhan ravi
el 9 de Dic. de 2018
see edited answer
AFHG
el 9 de Dic. de 2018
madhan ravi
el 9 de Dic. de 2018
ah.... which values?? then paramterize your function
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

