2

I testing different MATLAB solvers by implementing a simple equation in simulink dy/dx = y^2 - y^3 enter image description here

Now when i run this for ODE23 enter image description here

The output is enter image description here

Now when i run this for ode45the output is the same enter image description here enter image description here

Now as far as I know ode23 compares a second order and 3rd order solution compared to ode45 which compares a 4th order and 5th order solution so mathematically ode45 should give me a more accurate answer which it isn't now I don't know if i am doing something wrong in my MATLAB script that it isn't using different solvers as I am choosing the solver manually in my flame.slx file

clear all
clc

tic
sim('flame.slx',10)
toc

figure(1)
stem(tout,yout.signals.values)
xlabel('Time [sec]')
ylabel([]);
ylabel('Relative flame ball radious [%]')
figure(2)
stem(diff(tout))
xlabel('Steps [num]')
ylabel('Size [sec]')
5
  • 2
    The outputs of the solvers shouldn't be exactly the same but may be close when comparing plots. What is the normed difference between the outputs: norm(y45 - y23) (where y45 and y23 are the values from deval with the same x values)? And what is your initial condition? (If it is 0 or 1, the solutions will be constant).
    – TroyHaskin
    Commented May 5, 2015 at 20:21
  • Yes but the solutions are completely identical (I cannot add images due to my poor rating) ode45 should have been more precise , I am using 0.1 as initial for "y" in the integrator Commented May 5, 2015 at 20:26
  • 3
    They may look similar, but according to my R2014b install, they differ by about 2E-9 at x = 1 and it grows to about 7E-4 at x = 10. The normed difference on x = [0,10] is 5.1E-3. The answers are different. However, due to the error control built into the solvers, they will be similar enough when viewed via plotting.
    – TroyHaskin
    Commented May 5, 2015 at 20:34
  • Well the y axis is from 0 to 0.5 with step size of 5e-2 so i think difference of 5.1e-3 would be noticeable but they are completely identical , I dont have enough rating or i would have posted the images Commented May 5, 2015 at 20:38
  • 2
    With the MaxStep set to 5E-2, the normed difference is 8E-7 over x = [0,10] with y = [0.1,0.48], and the maximum point-wise difference is 1.1E-7. Setting the step size that low will bring the solutions closer to each other as the error is dependent on the step size. They may look similar when plotting the results, but they are not numerically the same.
    – TroyHaskin
    Commented May 5, 2015 at 21:02

0