ODE45 to solve a complicated problem

1 vue (au cours des 30 derniers jours)
Meredith Wirth
Meredith Wirth le 14 Août 2018
I'm trying to write a function that can be solved using ODE 45. My function is quite complicated. It is written as h'= T(h) x h. H represents the dipole headings. T represents torque and torque is written as the cross product between dipole headings and the magnetic field. To calculate the magnetic field, the displacement of the magnets is needed. How would I add this into the code?

Réponses (1)

Zenin Easa Panthakkalakath
Zenin Easa Panthakkalakath le 17 Août 2018
Hey Meredith,
Try to define the initial condition (h0), time interval between which you are trying to solve the ODE (tspan) first. For example,
tspan = [0,5]
h0 = 0
Then, call the ode45 function as shown below,
[t,h] = ode45(@odefun, tspan, h0)
Now, we need to define the 'odefun'. Since you require it to be h'= T(h) x h, define it as follows:
function dhdt = odefun(t,h)
dhdt = T(h) * h % You should define T(h) as well
end
For more information regarding how to use ODE45, please refer to the article here .
Regards, Zenin

Community Treasure Hunt

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

Start Hunting!

Translated by