MATLAB: Replicate integrator block in Ms Excel

integratorlaplace transformmatlab/simulink

Hi folks,
I created a simple diagram to solve ordinary differential equation as shown below.
I was trying to compute the result of xf_dot manually in Ms Excel but I did not get the same answer with the solution from Matlab.
The xl_dot is a table of time-value e.g ([0 30; 1 27; 2 24; . . .]) and initial value for integrator is zero. I suppose the result of xf_dot would be
xf_dot (t) = 0 + delta_v(t) * t
But when I computed the result in Ms Excel the data plot is different.
did I miss something here?
Thanks in advance

Best Answer

Hello Dedy Ariansyah,
I suppose that is caused by your integration method deviating from the one of Simulink. You can adjust the integration method in Simulink within the preferences(ode3 and such). Apparently your method is the explicit Euler method whereas Simulink possibly uses the classical Runge-Kutta method which has a much smaller error since the error is proportional to h^4 whereas the Euler-method's error is proportional to h. For this you first of all will need the differential equation which in your case seemingly is:
d^2xf(t)/dt^2 = xl'(t) - xf'(t)
Let's substitute the derivations like this:
F = xf'(t)
L = xl'(t)
=> F' = L - F
The next step is to implement(for example) the classical Runge-Kutta method within Excel. Read about the methods here( https://en.wikipedia.org/wiki/Runge%2525E2%252580%252593Kutta_methods ) and keep in mind the flexibility which the Butcher-Scheme provides. And then: Happy Excel-ing. ^^
With kind regards,
Raphael E
PS: Also note that Simulink normally has a variable-step h. But since implementing this in your Excel file would be too difficult I recommend switching to fixed-step.