feijuan1119 发表于 2008-5-25 11:20

求助:微分方程组程序报错

以前看过别人解微分方程组,但是关于t的函数,而我的这里T1,T2,T3,T4均为一些离散的数据点,我不知道这么用是否有问题
报错:
Error in ==> funfun\private\odearguments at 110
f0 = feval(ode,t0,y0,args{:});   % ODE15I sets args{1} to yp0.

Error in ==> ode45 at 173
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...

m文件
function dy=vdp_eq(t,y,I1,I2,I3,I4,I5,I6,c1,c2,c3,c4,h1,h2,h3,h4,h5,k1,k2,k3,k4,k5,T1,T2,T3,T4)
f=[y(2);
[-h1*(y(2)-y(4))-k1*(y(1)-y(3))]/I1;
y(4);
/I2;
y(6);
/I3;
y(8);
/I4;
y(9);
/I5;
y(11);
[-h5*(y(12)-y(10))-k5*(y(11)-y(9))]/I6];
end

以上为m文件
I1=0.005;
I2=0.0092;
I3=0.0082;
I4=0.0082;
I5=0.0091;
I6=0.1533;
k1=86000;
k2=508100;
k3=518200;
k4=505100;
k5=767200;
c1=0;
c2=0;
c3=0;
c4=0;
c5=0;
h1=1;
h2=1;
h3=1;
h4=1;
h5=1;


fig=fopen('D:Ttqsor1.dat','r')
T1=fscanf(fig,'%f')
fclose(fig)
T1=T1(1:720)

fig=fopen('D:Ttqsor2.dat','r')
T2=fscanf(fig,'%f')
fclose(fig)
T2=T2(1:720)

fig=fopen('D:Ttqsor3.dat','r')
T3=fscanf(fig,'%f')
fclose(fig)
T3=T3(1:720)

fig=fopen('D:Ttqsor4.dat','r')
T4=fscanf(fig,'%f')
fclose(fig)
T4=T4(1:720);

t_tent=719;
options = odeset('RelTol',1e-4,'AbsTol',);
= ode45(@vdp_eq,,,options,I1,I2,I3,I4,I5,I6,c1,c2,c3,c4,h1,h2,h3,h4,h5,k1,k2,k3,k4,k5,T1,T2,T3,T4);
plot(t,y(:,1),'-',t,y(:,2),'-.',t,y(:,3),'.')

xjzuo 发表于 2008-5-25 19:26

注意等号两边的数组维数应相等,此处似乎应该用循环,而不是直接用向量---即:可以考虑分组求解.
页: [1]
查看完整版本: 求助:微分方程组程序报错