MATLAB: ODE solvers for non-unique data

odeode45

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?

Best Answer

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?