MATLAB: Do the results from ODE45 and Simulink differ when applied on the same ordinary differential equation in MATLAB 7.9 (R2009b)

fixedMATLABode45simulinksolversstepvariable

When I solve the ordinary differential equation using Simulink and ODE45 function in MATLAB, they return different results. I use the fixed step ode4 (Runge Kutta) solver in Simulink to solve the ode.
Run the attached files lumped_parameter_P6_4.m and lumper_parameter.mdl and compare the output from both the methods. The maximum and the minimum output values are supposed to be 45 and 65 in both the cases. Simulink gives the correct output while ODE45 returns minimum and maximum values between 45 and 65.

Best Answer

The ODE45 is a variable step solver. Simulink solves the problem as a fixed step solver. The ODE45 can replicate the results of Simulink if a limit is imposed on the maximum step that it can take using the odeset function.
>> options = odeset('MaxStep',1);
Related Question