0

我在将四个二阶微分方程正确输入 ode.45 函数时遇到问题。

load parameters
t0=0:0.01:10;
X01=zeros(8,1);
for k = 1:length(xr)
    [t1,X2] = ode45(@(t,x)f1(t,x,dxr(k),dyr(k),xr(k),yr(k)),t0,X01);
end

和功能

function dX=f1(t,x,dxr,dyr,xr,yr)
m1=10;
mn=10;
p = 1;
R = 0.01;
u = 0.7;
ks = 1.5 * 10^8;
g=9.81;
F1r = ((yr - x(6))^p)*ks*(1 - ((1 - (R^2))/2)*(1 - sign(yr - 
x(6))*sign(dyr - x(2))));
T1r = -u * F1r * sign(x(1) - dxr);
F21 = ((x(6) - x(8))^p)*ks*(1 - ((1 - R^2)/2)*(1 - sign(x(6) - 
x(8))*sign(x(2) - x(4))));
T21 = -u * F21 * sign(x(3) - x(1));
M=zeros(8,8);
M(1,1) = m1;
M(2,2) = m1;
M(3,3) = m1;
M(4,4) = m1;
M(5,5) = 1;
M(6,6) = 1;
M(7,7) = 1;
M(8,8) = 1;
dx1=x(1,1);
dy1=x(2,1);
dx2=x(3,1);
dy2=x(4,1);
x1=x(5,1);
y1=x(6,1);
x2=x(7,1);
y2=x(8,1);
Q = [T1r - T21; F1r-m1*g-F21; T21; F21-m1*g; dx1; dy1; dx2; dy2];
dX=inv(M)*Q;
end

它只是卡住了,不会在 ode45 上执行单循环。

4

0 回答 0