ODE for 2 variables
Mostrar comentarios más antiguos
Hello all,
Does matlab support DE of this type: d(xy)/dt (ie. y dx/dt + x dy/dt)? If so how to werite these type of equations? I am a new comer to matlab and any help would be great!
Thanks.
2 comentarios
Torsten
el 6 de Ag. de 2019
You will need two equations to determine x and y. What is your second equation ?
Nivedhitha S
el 6 de Ag. de 2019
Respuesta aceptada
Más respuestas (1)
Steven Lord
el 6 de Ag. de 2019
1 voto
Write your equations in the form M*DV = RHS where:
, 
and M is the mass matrix. Since your second equation expands to:
the second row of your mass matrix will be [y, x, 0, 0]. Multiply that vector times DV and you'll see that you've recreated the left side of the second differential equation. Generate the remaining rows of the mass matrix similarly.
Create an options structure that specifies the mass matrix using odeset and the 'Mass' name-value pair. The value for that pair will be a function handle that accepts t (time) and the vector V and returns the mass matrix M.
Then write the function that evaluates RHS as a function of t and V. Call the ODE solver specifying that function and the options structure (so the solver knows how to create the mass matrix.
Categorías
Más información sobre Ordinary Differential Equations 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!