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 で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!