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!