How to solve the second-oder differential equations with two variables using ODE45 or whatever
显示 更早的评论
Hello,
I'm trying to solve the following equations using ODE45 but I'm not confident that my codes work correct. So please teach me whether the codes are correct or not, and if not, teach me how I can analyze the equation numerically.
----—the equation———
mx’’+Dx’+Kx=-f
Tf’ + f = Gx
%parameters
m=3
D=2
K=1
T=1
G=5
%variables
x, f
———my codes———
% I know ode45 only can solve one oder differential equations so I did a change of variables. However I would rather avoid using this change because it’s hard to see x and f in a plotted graph with the new variable appearing on it.
m=3
D=2
K=1
T=1
G=5
% I did the following change [X=x’] so the equation becomes[ X=x’ ][mX’+DX+Kx=-f][Tf’ + f = Gx]
%F(1) matches x, F(2) matches X, F(3) matches f
% x(0)=0.5
[t,F]=ode45(@(t,F)[F(2);(-F(3)-D*F(2)-K*F(1))/m;(G*F(1)+F(3))/T],[0,1],[0.5,0,0]);
plot(t,F);
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!