查看单个帖子
旧 2009-03-22, 20:01   #1
lohas1985
初级会员
 
注册日期: 2009-03-12
年龄: 39
帖子: 2
声望力: 0
lohas1985 正向着好的方向发展
默认 [求助]帮我看下matlab错误: index out of bounds

哪位兄弟帮我看下到底哪里错了?
sym u1
m=0.0001;
t=0.03;
il=0;
i3(1)=0;
i2(1)=0;
i=1;
for x=0:m:t
ie=0.1*cos(314.16*x);
if x==0
il=0;
else
il=il+0.00033*(u1-u2(i-1));
end
if x<0.001
i2(i)=0;
i3(i)=0;
else if x<0.002
i2(i)=-0.00752*u3(i-9);
i3(i)=-0.00752*u2(i-9);
else i2(i)=-0.00752*u3(i-9)-i3(i-19);
i3(i)=-0.00752*u2(i-9)-i2(i-19);
end
end
Y=[0.100167,-0.000167,0;
-0.000167,0.003903,0;
0,0,0.003737];
U=[u1;u2(i);u3(i)];
It=[ie;
0;
0];
I=[-il;
il-i2(i);
-i3(i)];
U=inv(Y)*(It+I);
plot(double(x),double(u3(i)));
hold on
i=i+1;
end
运行后系统出现
??? Attempted to access u2(2); index out of bounds because numel(u2)=1.

Error in ==> zuoye at 28
U=[u1;u2(i);u3(i)];
是不是矩阵不能这样运算?
lohas1985 当前离线   回复时引用此帖