Matlab ode solve takes too big steps?

  • Thread starter robijnix
  • Start date
  • Tags
    Matlab Ode
I also tried different solvers, but the problem still persists.In summary, the speaker is having trouble solving a set of differential equations using MATLAB's solvers. The states in the equations must stay between 0 and 1, but they are sometimes going below 0 or above 1. The speaker is confident that their equations are correct and has tried lowering the tolerance and using 'NonNegative', as well as different solvers, but the issue persists. They are seeking advice on how to fix this problem.
  • #1
robijnix
4
0

Homework Statement


I have a set of differential equations, which need to be solved by matlabs solvers. all of the states have to stay between 0 and 1, but they don't. I'm 100% sure my equations are right, but MATLAB is taking too big steps, causing the state to go negative or above 1.
most of the time it's only something like -10^6, but this is still wrong and causes a lot of problems. Sometimes the negative values don't stay that low and as state get a value like -400. Again, I'm sure my equations are right, and saying that they aren't isn't going to help me. If someone has any idea on how to fix this it would be greatly appreciated.
(also I'v tried lowering the tolerance and using 'NonNegative', and I'v tried all different solvers)
 
Physics news on Phys.org
  • #2
Homework Equations All of the equations I'm using are just basic differential equations. The Attempt at a SolutionI tried to lower the tolerance and using 'NonNegative', but that didn't help.
 

1) Why is my Matlab ode solver taking such large steps?

There could be several reasons for this. One possibility is that your integration tolerances are set too high, causing the solver to take larger steps in order to meet those tolerances. Another possibility is that your system of equations is stiff, meaning that the solution changes rapidly in certain regions, causing the solver to take larger steps to keep up.

2) How do I adjust the integration tolerances in Matlab ode solver?

You can adjust the integration tolerances by using the 'RelTol' and 'AbsTol' options in the 'odeset' function. Lowering these values will result in smaller steps being taken by the solver, potentially leading to a more accurate solution.

3) What is a stiff system of equations?

A stiff system of equations is one in which the solution changes rapidly in certain regions. This can be caused by a large difference in timescales between different variables in the system, or by the presence of highly nonlinear terms. Stiff systems can be more challenging for solvers to handle, as they may require smaller step sizes to accurately capture the solution.

4) Can I manually specify the step size in Matlab ode solver?

Yes, you can use the 'MaxStep' option in the 'odeset' function to specify the maximum step size that the solver can take. However, it is generally recommended to let the solver determine the appropriate step size for the given problem, as it is designed to do so in an efficient manner.

5) Are there any other ways to improve the performance of Matlab ode solver?

Yes, there are several ways to improve the performance of the solver. One approach is to use a more appropriate solver for your specific problem, such as a solver designed for stiff systems if you are dealing with a stiff system of equations. You can also try adjusting the initial conditions or reformulating your equations to be more numerically stable. Additionally, parallel computing can be used to speed up the solver for larger problems.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
2K
  • Advanced Physics Homework Help
Replies
1
Views
952
  • Differential Equations
Replies
6
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
3K
  • Introductory Physics Homework Help
Replies
4
Views
1K
  • Poll
  • Engineering and Comp Sci Homework Help
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
3K
Back
Top