How can I call the highest order solution (e.g. x'') of an ode in another ode?

1 次查看(过去 30 天)
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

采纳的回答

Alan Stevens
Alan Stevens 2021-2-24
编辑:Alan Stevens 2021-2-24
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.)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by