我正在尝试使用ode45
在 MAtlab 中并想要修复 MAtlab 使用的点数(时间步数)。使用'refine'
ode45
中的选项似乎没有帮助。例如,如果我设置 'refine'
如果为 10,Matlab 将返回一个 101 的数组。
改变'RelTol'
和'AbsTol'
也无济于事。我知道可以写tspan
如[0,t1,t2,t3,...,tn]
这解决了这个问题,但我想通过 'refine'
修复点数选项。
最佳答案
也许您误解了'Refine'
选项的实际作用。来自 odeset
的文档:
Refine — If Refine is 1, the solver returns solutions only at the end of each time step. If Refine is n >1, the solver subdivides each time step into n smaller intervals and returns solutions at each time point. Refine does not apply when length(tspan)>2 or the ODE solver returns the solution as a structure.
换句话说,将“Refine”设置为 10 并不能保证您将获得 10 个输出点,而是每个积分时间步长都会获得 10 个输出点嗯>。对于像 ode45 这样的自适应步长方法,求解器会根据许多标准选择步长的大小。如果您想要给定数量的输出点,则必须指定固定的时间步长,就像您已经通过 tspan 完成的那样。 linspace
函数可能对您有帮助。
另一种可能性是您并没有真正应用您的选项。仅仅调用 odeset 是不够的。您还必须记住将输出传递到 ode45
。
关于matlab - 在Matlab的ode45中使用 "Refine"选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20898040/