ODE for 2 variables
Mostra commenti meno recenti
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 Commenti
Torsten
il 6 Ago 2019
You will need two equations to determine x and y. What is your second equation ?
Nivedhitha S
il 6 Ago 2019
Risposta accettata
Più risposte (1)
Steven Lord
il 6 Ago 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.
Categorie
Scopri di più su Ordinary Differential Equations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!