How do I change these commands to plot different differential equations?

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:
MATLAB_2018-12-09_12-16-35.png

Respuestas (1)

madhan ravi
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

This is done with the values on the video:
I should be getting something like this:
MATLAB_2018-12-09_12-16-35.png
AFHG
AFHG el 9 de Dic. de 2018
Editada: AFHG el 9 de Dic. de 2018
Also, i think i didnt explain myself correctly, sorry about that.
The y and x both represent different populations.
On the y axes of my graph there should be the population number (so both x and y count as y values basically as they represent the population of two different species) while on the x axis there is time.
MATLAB_2018-12-09_12-16-35.png
"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!
AFHG
AFHG el 9 de Dic. de 2018
Editada: AFHG el 9 de Dic. de 2018
I expressed myself wrongly, give me a hand man
Do you know how to do that or?
Can't you solve it in the same way , I showed you? Read the documentation page to get familiar with ode solvers.
nope, if you see the graph i posted, i should get two different equations
see edited answer
those are example values in the video, i need different values (shown in the equations i asked), but i dont know how to change it
ah.... which values?? then paramterize your function

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Productos

Versión

R2018b

Preguntada:

el 9 de Dic. de 2018

Comentada:

el 9 de Dic. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by