When I use ode45 to solve a state space equation, the solution will be diverge. Interestingly, if I set the ma (which I've overstriked) to zero, the result will be converge.

1 回表示 (過去 30 日間)
clear
clc
xm_init = [0.09 0 0 0 0 0];
[t, xm] = ode45(@simplified_model, [0,200], xm_init);
plot(t,xm(:,1))
function dxm = simplified_model(t,xm)
kt = 1.8406e9;
kp = 1.3386e10;
ct = 5.2321e7;
cp = 2.35951e7;
It = 2.0444e9;
Ip = 3e9;
g = 9.8;
ma = 20000;
ka = 5000;
ca = 9000;
mt = 347460;
mp = 5452000;
Rt = 40;
Rp = 0.28;
Ra = 90;
M = [Ip 0 0
0 It 0
0 0 ma];
K = [kp+kt+mp*g*Rp -kt 0
-kt -mt*g*Rt+kt+ka*Ra*Ra+ma*g*Ra -ka*Ra-ma*g
0 -ka*Ra-ma*g ka];
C = [cp+ct -ct 0
-ct ct+ca*Ra*Ra -ct*Ra
0 -ct*Ra ca];
Am = zeros(6,6);
Am(1:3,4:6) =...
[1 0 0
0 1 0
0 0 1];
Am(4:6,1:3) =-M\K;
Am(4:6,4:6) =-M\C;
xm = [xm(1) xm(2) xm(3) xm(4) xm(5) xm(6)]';
dxm = Am*xm;
end

採用された回答

David Goodmanson
David Goodmanson 2024 年 12 月 17 日
編集済み: David Goodmanson 2024 年 12 月 17 日
Hi Z^2,
It's not easy to say for sure without seeing the actual model, but I think there is a decent chance that your C matrix should not be
C = [cp+ct -ct 0
-ct ct+ca*Ra*Ra -ct*Ra
0 -ct*Ra ca];
but rather
C = [cp+ct -ct 0
-ct ct+ca*Ra*Ra -ca*Ra
0 -ca*Ra ca];
i.e. the (2,3) and (3,2) elements go from ct to ca. That change produces the following plot:
  1 件のコメント
宗祥
宗祥 2024 年 12 月 17 日
Hi David
You're right! The problem is with my model, not with ode45!
Thank you very much for your help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by