4
$\begingroup$

I made a block diagram using simulink. When I solve it with ode45 and ode23 it gives me different graphs. Is it normal? Should I use the proper one?

m1=1.3608;
m2=0.096;
r=0.0592;
I2=0.0002175;
k1=186.3;
g=9.81;

Here is what the model looks like:

enter image description here

and the ode45 solution:

enter image description here

I can't post the ode23 solution but it is very different.

$\endgroup$
5
  • 1
    $\begingroup$ Why can't you post the ode23 solution? How is it different? What solver parameters are you using in each case? $\endgroup$ – am304 Apr 15 '16 at 11:00
  • 2
    $\begingroup$ The answer is no. If you are getting different solutions, then you can't trust either one. You most likely need to set the time-step parameter to be smaller. $\endgroup$ – Chris Mueller Apr 15 '16 at 11:33
  • 2
    $\begingroup$ As the solution is calculated numerically, small differences can exist between solutions when using different solvers or when using the same solver but with different solver settings. But the solutions should not differ fundamentally. In the latter case, you might have used an inappropriate solver or solver setting. $\endgroup$ – Karlo Apr 15 '16 at 11:41
  • 1
    $\begingroup$ What you have here looks to be stiff. It looks to me that the solver alternates between 2 possible solutions. $\endgroup$ – joojaa Apr 16 '16 at 3:39
  • $\begingroup$ Check for the parameters of the ode45 and ode23 functions. They might be using different initial conditions. $\endgroup$ – leCrazyEngineer Jul 17 '16 at 1:59
1
$\begingroup$

ode solvers are all different. I've recently compared several fixed-time-step and variable-time-step ode solvers, with the same initial conditions, with the same model. Summary: They all give different solutions, sometimes fundamentally different.

Matlab/Simulink documentation gives a rough outline of picking the most useful (not the BEST) solver for the application under consideration.

Choose an ODE solver

Matlab Answers page

Decision tree to pick an ODE solver

about ordinary differential equations

The basic idea is:

  1. start with a variable time-step solver (ode45, for example)
  2. if solver performance is not as desired (too long to compute a timestep), start with the simplest method (ode1 Euler) and iteratively try higher order solutions until you arrive at an acceptable accuracy.

If you do not have design constraints like using a fixed-time-step ode solver, going with the highest one that you can afford (ode45?) would be the best idea.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.