Hi… I have tried to solve a set of non-linear coupled differential equations in matlab by rk4 method. For this i have written a code (but not used any solver like ode45)but during validation results are not matching. Then i have solved a simple equation y'=2*t,y(0)=0 t=[0:0.5:2] the results obtained by the code rk4 exactly matches with ode45 solver. Thats correct means code is working fine. Then i have solved several simple problems from text books of matlab, most cases results are matching. Then i have tried to solve a problem y'=2*t^5; with y(0)=0 t=[0:0.5:2]. But the results obtained by ode45 exactly matches with analytical solution, but results obtained by my own code deviates more, then i have copied a code from text book "APPLIED NUMERICAL METHODS USING MATLAB" by Yang et al. page number 268. The results obtained by my own code matches with results of book code but results of both code deviates from ode45 and analytical results. anybody please tell me the reason behind it…
MATLAB: Difference in ode45 and rk4 code
MATLABode45
Best Answer