Argument 'range' for ode45

4 views (last 30 days)
Douglas Alves
Douglas Alves on 9 Jun 2014
Commented: Douglas Alves on 10 Jun 2014
I have just found out that ode45(@fun,tspin,x) can have instead of tspin = [value1 value2]. tspin could be a linspace(a,b,c) where a,b and c are numbers. What's the difference between these kinds of tspins? I thought it should be only 2 values because integration from value1 to value2. How should I set up tspin in case it's a 3D integration? 6 values should be put in tspin? If so, may this problem have a dimension much bigger than a 3D ?

Accepted Answer

Mischa Kim
Mischa Kim on 10 Jun 2014
Edited: Mischa Kim on 10 Jun 2014
Douglas, to your first question you would choose linspace if you want the ode solver to return solutions at specific times. If you do not really care about the solution at specific times, simply go with tspin = [value1 value2], where value1 and value2 correspond to a and b.
As far as your second question is concerned I assume you are hinting at partial differential equations, which you would solve with the PDE toolbox.
  3 Comments
Mischa Kim
Mischa Kim on 10 Jun 2014
Correct. Both approaches give you the same answer, also in terms of accuracy. The only difference is that with the second approach you tell MATLAB at which time points you want an output of the solution. If you do not specify time points MATLAB will do it for you, again, without loss of accuracy.
Accuracy is determined by the solver settings.
Douglas Alves
Douglas Alves on 10 Jun 2014
Thank you very much Mischa.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!