ODE45 to solve a complicated problem
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Meredith Wirth
el 14 de Ag. de 2018
Respondida: Zenin Easa Panthakkalakath
el 17 de Ag. de 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?
0 comentarios
Respuestas (1)
Zenin Easa Panthakkalakath
el 17 de Ag. de 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
Regards, Zenin
0 comentarios
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!