How to set Variable-step in ODE15s?
显示 更早的评论
I am trying to solve ODE using ODE15s, but when I change the Variable-step, the result changes. So how to set the step? Thanks.
[t,N]=ode15s(odefun,[0:5:2000],NN0);
The resulet is like the first image. When I changed the step to 10,the result is like the second image.
4 个评论
"The resulet is like the first image. When I changed the step to 10,the result is like the second image."
They both look fine to me. When you change the requested t values, of course the outputs will be different. And for a curve with such a sharp peak like that, of course the curves might look slightly different. I don't see what the problem is.
Plot them on the same axes, or set the Y limits to be the same, and you will see that they are the same curve.
ZHUEN RUAN
2018-10-5
KSSV
2018-10-5
plot both the curves on the same using hold on then you will get know.....use different steps and plot..at one time step..your values get converged..this would be the required time step.
ZHUEN RUAN
2018-10-5
采纳的回答
更多回答(1 个)
Bruno Luong
2018-10-5
编辑:Bruno Luong
2018-10-5
[t,N]=ode15s(odefun,[0:5:2000],NN0);
Don't be confuse, the vector in tspan does not specify the solver step, just the solution values to be output at intermediate points you have specified.
类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

