Writing ODE equations for ode45 to solve;
48 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Noob
am 30 Okt. 2024 um 17:45
Bearbeitet: Torsten
am 30 Okt. 2024 um 18:56
Hi there!
I have a basic question to ask here, regarding writing the first-order equations for ode45 to solve.
Let's say I am solving Newton's 2nd law equations of motion F = ma.
In my function file, the left-hand-side of each equation will be:
- vx (velocity of x-component)
- vx (velocity of y-component)
- omega (angular velocity)
- ax (acceleration of x)
- ay (acceleration of y)
- omegadot (angular acceleration)
For equations 4, 5, 6, I need to use Newton's law ma = F.
Should I write ma = F as is, or do I need to isolate ax, ay, and omegadot, by dividing both sides by the mass m and the moment of inertia I, respectively? My LHS m*a is pretty lengthy, after using the product rule, chain rule, etc., so I wonder if I can just keep it as is, ma = F.
I then create an anonymous function that calls the above function, and this anonymous function is passed into ode45.
Updafe: I just tinkered with this a bit, and it does seem that I can write ma = F as is, but I have to use the double == sign, to equate values from each side, and that the single = sign is for assigning a value to a variable name. Please let me know if you have other thoughts to share.
Thanks!
0 Kommentare
Akzeptierte Antwort
Torsten
am 30 Okt. 2024 um 18:22
Verschoben: Torsten
am 30 Okt. 2024 um 18:22
The form of the equations that can be solved by ode45 is M*y'(t) = f(t,y). So you can decide whether you choose M to be the identity matrix (that is: whether you isolate ax, ay and omegadot) or not.
6 Kommentare
Torsten
am 30 Okt. 2024 um 18:55
Bearbeitet: Torsten
am 30 Okt. 2024 um 18:56
Numerical assignments only use the single "=" sign. I don't know what you try to do in your function file.
If you want to set something like
a11*y1' + a12*y2' + a13+y3' = f1
you will have to set the elements a11, a12 and a13 in the mass matrix M and the expression for f1 in your function of the right-hand side.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!