ODE45 to solve a complicated problem
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Zenin Easa Panthakkalakath
2018 年 8 月 17 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!