How can I call the highest order solution (e.g. x'') of an ode in another ode?
1 view (last 30 days)
Show older comments
Leonie Schickmann
on 24 Feb 2021
Commented: Leonie Schickmann
on 24 Feb 2021
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
0 Comments
Accepted Answer
Alan Stevens
on 24 Feb 2021
Edited: Alan Stevens
on 24 Feb 2021
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.)
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!