马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
下面是我参考一些资料编的模型参考自适应控制程序,可运行时出了错误,说?? In an assignment A(I) = B, the number of elements in B and
I must be the same.
Error in ==> d:\MATLAB6p1\work\adaptivelyaptesting.m
On line 23 ==> ym(k)=cm*Xm(1);到底问题在哪儿啊,大家帮我看看!谢谢!
Ap=[-9 -292;1 0];Bp=[1 0]';
cp=[9 292];
Am=[-60 -1500;1,0];Bm=[1,0]';
cm=[1,20];
Xm=[0;0];Xp=[0;0];
h=0.06;N=1000;
r1=sin([1:N]*h);
r0=-0.3*r1;
T1=.3;T2=.1;
K=0.1;dK=0;
F=[-0.1 0.4];dF=[0 0];
P=lyap(Am,eye(2))
for jj=1:10
for k=1:N
r=r0(k);
k0=Am*Xm+Bm*r;
k1=Am*(Xm+h*k0/2)+Bm*r;
k2=Am*(Xm+h*k1/2)+Bm*r;
k3=Am*(Xm+h*k2)+Bm*r;
Xm=Xm+h*(k0+2*k1+2*k2+k3)/6;
ym(k)=cm*Xm(1);
u=K*r+F*Xp;
k0=Ap*Xp+Bp*r;
k1=Ap*(Xp+h*k0/2)+Bp* u;
k2=Ap*(Xp+h*k1/2)+Bp*u;
k3=Ap*(Xp+h*k2)+Bp*u;
Xp=Xp+h*(k0+2*k1+2*k2+k3)/6;
yp(k)=cp*Xp(1);
e=Xp-Xm;
dK1=dK;
dK=T2*(Bm*K)'*P*e*r;
K=K+(dK+dK1)*h/2;
dF1=dF;
dF=T1*(Bm*K)'*P*e*Xp';
F=F+(dF+dF1)*h/2;
end
if jj==1
figure(1)
plot([1:N]*h,ym,'k-',[1:N]*h,yp,'r:')
title('The response of the adaptive control system(start period)')
xlabel('t(second)'),ylabel('Amplitude')
end
end
figure(2)
plot([1:N]*h,ym,'k-',[1:N]*h,yp,'r:')
title('The response of the adaptive control system(stop period)')
xlabel('t(second)'),ylabel('Amplitude')
e2=ym-yp;
figure(3)
plot([1:N]*h,e2,'k-') |