千山之巅 发表于 2014-7-22 14:48:32

高手留步,MATLAB解DAE问题





解上图方程,以下是我的求解程序


k=1.1;
n=0.8;
odefun=@(t,x)[-n*pi*x(2)^2*x(4);%t对应theta,x(1)对应V,x(2)对应R,x(3)对应z,想(4)对应dz
    -1/(tan(k*t))*x(4);
    x(4);
    x(1)*(sin(t))^3-pi/3*(x(2)^3)*((2-3*cos(t)+(cos(t))^3))];
tspan=;
x0=;
M=eye(4,4);
M(4,4)=0;
options=odeset('Mass',M);
=ode23t(odefun,tspan,x0,options);
但总是提示
Error using daeic12 (line 77)This DAE appears to be of index greater than 1.
Error in ode23t (line 289)    = daeic12(odeFcn,odeArgs,t,ICtype,Mt,y,yp0,f0,...
Error in bingye (line 12)=ode23t(odefun,tspan,x0,options);

TBE_Legend 发表于 2014-7-27 13:16:24

不会matlab,用mathematica做了下

TBE_Legend 发表于 2014-7-27 13:16:44

t0 = 0.1; tend = Pi/2;
Manipulate[
{rsol, zsol, vsol} =
NDSolveValue[{r' == (-z')/Tan[ k t],
   v' == n (Pi r^2 z'),
   v/r^3 == (Pi/3) ((2 - 3 Cos + Cos^3)/Sin^3),
   v == Pi/3, r == 1, z == 1}, {r, z, v}, {t, t0,
   tend}] // Quiet;
Plot[{rsol, zsol, vsol}, {t, t0, tend},
AxesLabel -> Automatic, PlotTheme -> "Detailed",
PlotLegends -> "Expressions"], {k, 0.1, 1}, {n, 0.1, 1}]
页: [1]
查看完整版本: 高手留步,MATLAB解DAE问题