I testing different MATLAB solvers by implementing a simple equation in simulink dy/dx = y^2 - y^3
Now when i run this for ODE23
The output is
Now when i run this for ode45the output is the same
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]')
norm(y45 - y23)
(wherey45
andy23
are the values fromdeval
with the samex
values)? And what is your initial condition? (If it is0
or1
, the solutions will be constant).2E-9
atx = 1
and it grows to about7E-4
atx = 10
. The normed difference onx = [0,10]
is5.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.MaxStep
set to5E-2
, the normed difference is8E-7
overx = [0,10]
withy = [0.1,0.48]
, and the maximum point-wise difference is1.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.