MATLAB: How to call the highest order solution (e.g. x”) of an ode in another ode

MATLABodeode45

I want to solve the following differential equations, a-f are known variables which are manually set before solving the equations:
u'' = -a/d*u' – b/d*u – x''
x''= (c+d)^(-1)*( – e*x' – f*x – d*u'')
I do not know how to call x'' in the first and u'' in the second ode. My approach (given below) does run, but the results are wrong (u and u' are always 0). How do I implement my equations correctly?
The code I tried to use:
tspan = [0 200];
z0 = [0; 0; 5; 0];
[t,z] = ode45(@(t,z)f(t,z),tspan, z0);
function dzdt = f(t,z)
u = z(1:2);
x = z(3:4);
% Definition of a-f here
dzdt = zeros(4,1);
dzdt(1) = u(2);
dzdt(2) = -a/d *u(2)-b/d *u(1)-dzdt(4);
dzdt(3) = x(2);
dzdt(4) = (c+d)^(-1)*(-e*x(2)-f*x(1)-d*dzdt(2));
end

Best Answer

You can rearrange the equations as follows to get a consistent set:
(you will need to use explicit multiplication where my equations have implicit multiplication. For example,
where I have fx(1) you will need f*x(1) etc.)