声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 803|回复: 1

[编程技巧] 求助:微分方程组程序报错

[复制链接]
发表于 2008-5-25 11:20 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
以前看过别人解微分方程组,但是关于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);
[T1-h1*(y(4)-y(2))-h2*(y(4)-y(6))-c1*y(4)-k1*(y(3)-y(1))-k2*(y(3)-y(5))]/I2;
y(6);
[T2-h2*(y(6)-y(4))-h3*(y(6)-y(8))-c2*y(6)-k2*(y(5)-y(3))-k3*(y(5)-y(7))]/I3;
y(8);
[T3-h3*(y(8)-y(6))-h4*(y(8)-y(9))-c3*y(8)-k3*(y(7)-y(5))-k4*(y(7)-y(9))]/I4;
y(9);
[T4-h4*(y(10)-y(8))-h5*(y(10)-y(12))-c4*y(10)-k4*((9)-y(7))-k5*(y(9)-y(11))]/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',[1e-4]);
[t,y] = ode45(@vdp_eq,[0 t_tent],[0 100 0 100 0 100 0 100 0 100 0 100],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),'.')
方程.bmp
回复
分享到:

使用道具 举报

发表于 2008-5-25 19:26 | 显示全部楼层
注意等号两边的数组维数应相等,此处似乎应该用循环,而不是直接用向量---即:可以考虑分组求解.

评分

1

查看全部评分

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-11-29 04:14 , Processed in 0.064259 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表