MATLAB: Comparing two arrays of different length with time values (ode45 vs. RK4)

deviationdifferent length arrayode45rk4

Hi everyone,
I'm currently working on a uni project in which I want to compare the results of the standart ode45 solver with a Runge-Kutta-4 based solver I implemented myself.
So in the end I would like to compare the two result arrays and plot the deviation of the results over time.
The problem I'm having is that the ode45 solver has a variable timestep and my own RK4 based solver doesn't so the result arrays have different lengths.
Is there a way I can calculate the deviation of both results and plot them over time? I tried using the imresize() function to bring the arrays to the same length, the timestep sizes however were still very different so the results didn't make any sense.
I assume there is a way to interpolate the data to get the to the same timestep size but I'm still quite new to Matlab and programming in general so I'm having trouble finding a solution.
Thanks and best regards
Paul

Best Answer

Read about intepr1. Get both the curves to the same timestamp/ same step size/ same dimension and compare.
Related Question