我的程序如下,和书上写的一样,为什么会出现错误“下标索引必须是正整数或逻辑值”谢谢 clear all; close
ts=1;sys=tf(0.31,[62.38,1,0]);dsys=c2d(sys,ts,'z');[num,den]=tfdata(dsys,'v')x=[0,0,0...
ts=1;
sys=tf(0.31,[62.38,1,0]);
dsys=c2d(sys,ts,'z');
[num,den]=tfdata(dsys,'v')
x=[0,0,0]';
xiteP=0.40;
xiteI=0.35;
xiteD=0.40;
wkp_1=0.30;
wki_1=0.30;
wkd_1=0.30;
error_1=0;
error_2=0;
y_1=0.0;y_2=0.0;y_3=0.0;
u_1=0;u_2=0;u_3=0;
for k=1:1:1000
time(k)=k*ts;
rin(k)=5.0;
yout(k)=-den(2)*y_1-den(3)*y_2+num(2)*u_1+num(3)*u_2 ;
error(k)=rin(k)-yout(k);
wkp(k)=wkp_1+xiteP*error(k)*u_1*(2*error(k)-error_1);
wki(k)=wki_1+xiteI*error(k)*u_1*(2*error(k)-error_1);
wkd(k)=wkd_1+xiteD*error(k)*u_1*(2*error(k)-error_1);
k=0.12;
end
x(1)=error(k)-error_1;
x(2)=error(k);
x(3)=error(k)-2*error_1+error_2;
wadd(k)=abs(wkp(k))+abs(wki(k))+abs(wkd(k));
w11(k)=wkp(k)/wadd(k);
w22(k)=wki(k)/wadd(k);
w33(k)=wkd(k)/wadd(k);
u(k)=u_1+k*(w11(k)*x(1)+w22(k)*x(2)+w33(k)*x(3)); 展开
sys=tf(0.31,[62.38,1,0]);
dsys=c2d(sys,ts,'z');
[num,den]=tfdata(dsys,'v')
x=[0,0,0]';
xiteP=0.40;
xiteI=0.35;
xiteD=0.40;
wkp_1=0.30;
wki_1=0.30;
wkd_1=0.30;
error_1=0;
error_2=0;
y_1=0.0;y_2=0.0;y_3=0.0;
u_1=0;u_2=0;u_3=0;
for k=1:1:1000
time(k)=k*ts;
rin(k)=5.0;
yout(k)=-den(2)*y_1-den(3)*y_2+num(2)*u_1+num(3)*u_2 ;
error(k)=rin(k)-yout(k);
wkp(k)=wkp_1+xiteP*error(k)*u_1*(2*error(k)-error_1);
wki(k)=wki_1+xiteI*error(k)*u_1*(2*error(k)-error_1);
wkd(k)=wkd_1+xiteD*error(k)*u_1*(2*error(k)-error_1);
k=0.12;
end
x(1)=error(k)-error_1;
x(2)=error(k);
x(3)=error(k)-2*error_1+error_2;
wadd(k)=abs(wkp(k))+abs(wki(k))+abs(wkd(k));
w11(k)=wkp(k)/wadd(k);
w22(k)=wki(k)/wadd(k);
w33(k)=wkd(k)/wadd(k);
u(k)=u_1+k*(w11(k)*x(1)+w22(k)*x(2)+w33(k)*x(3)); 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询