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.

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

 Accepted Answer

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 Comment

Hi David
You're right! The problem is with my model, not with ode45!
Thank you very much for your help!

Sign in to comment.

More Answers (0)

Products

Release

R2022b

Tags

Asked:

on 16 Dec 2024

Commented:

on 17 Dec 2024

Community Treasure Hunt

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

Start Hunting!