There's not enough information here to say for certain, but I have a hunch.
When you specify t0 and tf, the ode solver automatically determines the number of points in the solution. Where you are running 4 different solutions, it is likely at least one of them has a different number of points in the output. This becomes an issue because you overwrite t each time you call ode45. Each plot will use the final value of t as the input for x, and when the number of x and y points are not the same, you will get this error message.
Assuming this is your error - I'd have to see the complete error message to say for certain - you have a couple options.
- Use different variables to capture the output of each call to ode45 (i.e. [t1, y1], [t2, y2], etc.)
- Specify a time vector for tspan. You can read more about this input argument here.
Best Answer