Although actually upon further inspection the error might be coming from 'interp1' as opposed to the ODE solver. Is there a way around this?
ODE solvers for non-unique data
1 次查看(过去 30 天)
显示 更早的评论
So at the moment I am using ODE45 to solve an ode for some data that I have. ODE45 does not seem to like data that is not unique. E.g. I have 3 measurements at a time T, but it will not use this. Therefore I have calculated the means at each time point and solved it this way which works nicely. I am just wondering if there is an ODE solver that does not require unique data?
采纳的回答
John D'Errico
2018-4-24
编辑:John D'Errico
2018-4-24
ode45 does not use "data", so this is not really relevant to ode45.
However, interp1 does do interpolation. And interpolation is not meaningful if you have multiple points with the same independent variable, and distinct values for the dependent variable.
The idea is that interpolation returns the exact y, for any given x. But if you have some x that has three distinct values for y, then which of them should it return?
What is typically done is to use the average y if you have replicated x values replacing those multiple values with a single point. That is exactly what you did, and is about all you can ask for in context.
Be careful if someone tells you to perturb the x values slightly, which would in theory allow interp1 to succeed. That will also introduce HUGE local gradients into the problem. If a spline interpolant were used, that would in turn create wild oscillations. Even linear interpolation can have issues.
For example, given the set of points...
x = [0 1 1 1 2];
y = [1 2 3 4 5];
At x == 1, what is the value of y? 2, 3, or 4?
更多回答(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!