马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
这是啥原因?刚性问题?还是稳定性问题,谢谢指教。其中da/a是一个 微分计算,不过a的函数a(z)已经知道,以上可变系数方法对不对?
函数定义:
function xdot = fun2(t,x)
global da;
global a;
if (t>=0 )&(t<0.43379)
a=(-0.57735 * t + 0.810) ^ 2 * 3.14159265235 - (0.267949 * t + 0.240) ^ 2 * 3.14159265235 ;
da=2*-0.57735*(-0.57735 * t + 0.810) * 3.14159265235 - 2*(0.267949 * t + 0.240)*0.267949 * 3.14159265235 ;
end
if (t>=0.43379 )&(t<0.73826)
a=((-sqrt(0.420 ^ 2 - (t - 0.64379) ^ 2) + 0.92328) ^ 2 * 3.14159265235) - (0.267949 * t + 0.240) ^ 2 * 3.14159265235;
da=2*(-sqrt(0.420^2-(t-0.64379)^2)+0.92328)*(2*t-1.28758)/(2*sqrt(-t^2+1.287582*t-0.2380655841))- (0.267949 * t + 0.240)*0.267949 * 2 * 3.14159265235;
end
if (t>=0.73826 )&(t<2.090)
a=(0.230868 * (t - 2.410) + 0.900) ^ 2 * 3.14159265235 - (0.267949 * t + 0.240) ^ 2 * 3.14159265235;
da= 2*(0.230868 * (t - 2.410) + 0.900)*0.230868 * 3.14159265235 - 2*(0.267949 * t + 0.240)*0.267949 * 3.14159265235;
end
if (t>=2.090 )&(t<2.410)
a = (0.230868 * (t - 2.410) + 0.900) ^ 2 * 3.14159265235 - (-(t - 2.090) + 0.800) ^ 2 * 3.14159265235;
da=2*(0.230868 * (t - 2.410) + 0.900) *0.230868*3.14159265235 - 2*(-(t - 2.090) + 0.800) * 3.14159265235;
end
k=1.4;
m=x(1)/sqrt(k*287*x(4));
xdot(1) = x(1)*(1/(m^2-1))*(da/a);
xdot(2) = x(2)*(k*m^2/(1-m^2))*(da/a);
xdot(3) = x(3)*(k*m^2/(1-m^2))*(da/a);
xdot(4) = x(4)*((k-1)*m^2/(1-m^2))*(da/a);
xdot(5)=x(5)*(-2-(k-1)*m^2)/(2*(1-m^2))*(da/a);
xdot=xdot(:); % To make xdot a column
% End of FUN2.M
调用:
t0=0;tf=2.41;nsteps=1000;
tspan = linspace(t0, tf, nsteps);
用定步长:[t,x]=ode45(@fun2,tspan,[30,250000,2.55,343,30/sqrt(1.4*287*343)])
用变步长:[t,x]=ode45(@fun2,[0 2.41],[30,250000,2.55,343,30/sqrt(1.4*287*343)]) |