24小时热门版块排行榜    

查看: 488  |  回复: 0

lin007zhen

铁虫 (初入文坛)

[求助] 求助,微分代数方程组

function dx = yuanpan4(t,x)
m=10;r=0.5;k=100;g=9.8;u=0.4;
dx=zeros(5,1);
if x(4)>0
    dx(1)=x(2);
    dx(2)=(-k*x(1)+x(5))/m;
    dx(3)= (-2*x(5))/(m*r);
    dx(4)=x(2)-r*x(3)-x(4);
    dx(5)= x(5)+m*g*u;
elseif x(4)==0
    dx(1)=x(2);
    dx(2)=(-k*x(1)+x(5))/m;
    dx(3)=(-2*x(5))/(m*r);
    dx(4)=x(2)-r*x(3)-x(4);
    dx(5)=0;
else
    dx(1)=x(2);
    dx(2)=(-k*x(1)+x(5))/m;
    dx(3)=(-2*x(5))/(m*r);
    dx(4)=x(2)-r*x(3)-x(4);
    dx(5)=x(5)-m*g*u;
end
end
这是函数。
tspan=[0,16];
x0=[3;3;5;0.5;-39.2];
M=diag([1,1,1,0,0]);
options=odeset('Mass',M,'RelTol',1e-6,'AbsTol',[1e-10,1e-10,1e-10,1e-10,1e-10]);
[t,x]=ode15s(@yuanpan4,tspan,x0,options);plot(t,x(:,1),'-b',t,x(:,4),'-r',t,x(:,5),'-g');
grid on;
这是主程序。
Warning: Failure at t=1.192445e-02.  Unable to meet integration tolerances without reducing the step size
below the smallest value allowed (2.775558e-17) at time t.
这是错误提示
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

相关版块跳转 我要订阅楼主 lin007zhen 的主题更新
信息提示
请填处理意见