搜索内容 搜索用户

# [未答复] 用ode45报错：在时间 t 处，步长大小必须降至所允许的最小值以下，才能达到积分容差要求

 本帖最后由 三明 于 2021-11-25 01:17 编辑 clear all;clc; global rhox rhoy rhoz L D v=[1,0,0,0,0,0]; D=diag(v); L = [1,0,-1,0,0,0;     -1,1,0,0,0,0;     0,-1,2,0,0,-1;     -1,0,0,1,0,0;     0,0,0,-1,1,0;     0,0,0,0,-1,1]; x1(:,1) = [-0.6126 -0.1024 -0.3871]'; x2(:,1) = [-0.1844 -0.5441 -0.3192]'; x3(:,1) = [ 0.6552  0.4631 0.7302]'; x4(:,1) = [ 0.9520  0.936 0.5821]'; x5(:,1) = [-0.1313 -0.5469 -0.2821]'; x6(:,1) = [ 0.8313  0.7849 0.9214]'; x0(:,1) = [      1 -0.6536 0.3419]'; X=[1;-0.6126;-0.1844;0.6552;0.952;-0.1313;0.8313;1;1;1;1;1;1;    -0.6536;-0.1024;-0.5441;0.4631;0.936;-0.5469;0.7849;1;1;1;1;1;1;    0.3419;-0.3871;-0.3192;0.7302;0.5821;-0.2821;0.9214;1;1;1;1;1;1]; tBegin = 0; tFinal = 100; tFault = 5; [t,out]=ode45('odefun',[tBegin,tFinal],X);复制代码function out = odefun(t,X) global  rhox rhoy rhoz L D %% %k=1 if t >= 5     rhox =[0.2+0.8*exp(5-t);1;1;1;1;0.1+0.9*exp(5-t)];     rhoy =[0.1+0.9*exp(5-t);1;1;1;1;0.3+0.7*exp(5-t)];     rhoz =[0.2+0.8*exp(5-t);1;1;1;1;0.2+0.8*exp(5-t)]; else     rhox =[1;1;1;1;1;1];     rhoy =[1;1;1;1;1;1];     rhoz =[1;1;1;1;1;1]; end xlx = X(1,:);%k=1时的leader状态 xfx = X(2:7,:);%%k=1时的follower1-follower6状态 thetax = X(8:13,:); ksix = L*xfx+D*(xfx-xlx*ones(6,1)); ufx = diag(rhox*(diag(-5*diag(thetax*(ones(6,1)+ksix.^6)')*ksix'))'); dxlx = 0.5*(sin(xlx)+xlx) + t; dxfx = 0.5*(sin(xfx)+xfx) + ufx +t; dthetax = ksix.^2; %% %k=2 xly = X(14,:); xfy = X(15:20,:); thetay = X(21:26,:); ksiy = L*xfy+D*(xfy-xly*ones(6,1)); ufy = diag(rhoy*(diag(-5*diag(thetay*(ones(6,1)+ksiy.^6)')*ksiy'))'); dxly = 0.5*(sin(xly)+xly) + t; dxfy = 0.5*(sin(xfy)+xfy) + t + ufy; dthetay = ksiy.^2; %% %k=3 xlz = X(27,:); xfz = X(28:33,:); thetaz = X(34:39,:); ksiz = L*xfz+D*(xfz-xlz*ones(6,1)); ufz = diag(rhoz*(diag(-5*diag(thetaz*(ones(6,1)+ksiz.^6)')*ksiz'))'); dxlz = 0.5*(sin(xlz)+xlz) + t; dxfz = 0.5*(sin(xfz)+xfz) + ufz +t; dthetaz = ksiz.^2; %% out=[dxlx;dxly;dxlz; dxfx; dxfy; dxfz; dthetax; dthetay; dthetaz]; end复制代码 利用ode45解一组微分方程，其中rho是时变的，所以在function里面加入了if语句。 在t=5.81016877830341e-05处，出现： “警告: 在 t=5.810169e-05 处失败。在时间 t 处，步长大小必须降至所允许的最小值(1.084202e-19)以下，才能达到积分容差要求。” 请问各位大神，我该怎么修改呢？
 您需要登录后才可以回帖 登录 | 注册 本版积分规则 回帖后跳转到最后一页