2nd order differential errors
显示 更早的评论
Hi,
I am having issues with ODE45,
My function
function dydt=solver(y,t)
Caller
tspan = [0:0.01:3.12];
thrust=6;
g=9.81;
R=1.3;
m12=4.3;
回答(1 个)
William Rose
2021-4-15
0 个投票
Are you getting an error message? If so, what?
I notice that your dydt is mising a "*" after C.
3 个评论
John Masters
2021-4-15
William Rose
2021-4-15
the order of the input arguments to dydt=solver() should be (t,y) not (y,t)
William Rose
2021-4-15
编辑:William Rose
2021-4-15
@John Masters The code works when you fix the (t,y) ordering. By the way, you can specify just the start and end time in [tspan]. YOu don;t have to tell it the time step . That results in a more efficient execution because in that case, ode45() adapts the step size as it goes, as need to achieve a certain level of accuracy. See attached image. When I used you code as is, there were 313 evenly space time steps. When I only specified the start and end
tspan = [0,3.12];
there were 105 unevenly spaced times, with a concentration around the "glitch" (staging, perhaps?). See figure below. Code attached.

类别
在 帮助中心 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!