预测控制DMC算法matlab.txt资料文档下载
《预测控制DMC算法matlab.txt资料文档下载》由会员分享,可在线阅读,更多相关《预测控制DMC算法matlab.txt资料文档下载(3页珍藏版)》请在冰点文库上搜索。
fori=1:
length(p)
r=p(i);
ifr>
0%����ijһ�������ʵ����ʵ�������㣬��Ϊ���ȶ�ϵͳ��DMC������
p,G%���������ʾ����ʹ���
Error=('
��Ҫ���ƵĶ���Ϊ���ȶ�ϵͳ��DMC�㷨ֻ�������ȶ�ϵͳ!
'
)
return
end
end
%����DMC����
Ts=input('
��������Ts='
%����ʱ��
P=input('
Ԥ��ʱ��P='
%Ԥ�ⲽ��
M=input('
����ʱ��M='
%���Ʋ���
N=80;
%�ضϲ���
%�趨�ο�ֵ
yr=10;
%ϵͳ�������
%����ϵͳ��Ծ��Ӧģ��
[y0,t0]=step(G,0:
5:
500);
%��ʼ��DMC
A=zeros(P,M);
%��̬����
a=zeros(N,1);
N
a(i)=y0(i);
P
forj=1:
M
ifi-j+1>
A(i,j)=a(i-j+1);
%�������A
end
end
%��ʼ������ys��y,u,e�;���A0
ys=ones(N,1);
y=zeros(N,1);
u=zeros(N,1);
e=zeros(N,1);
A0=zeros(P,N-1);
forj=N-2:
-1:
1
ifN-j+1+i-1<
=N
A0(i,j)=a(N-j+1+i-1)-a(N-j+i-1);
%�������A0
else
A0(i,j)=0;
A0(i,N-1)=a(i+1);
%DMC����
fork=2:
Uk_1=zeros(N-1,1);
fori=1:
N-1
ifk-N+i<
=0
Uk_1(i)=0;
Uk_1(i)=u(k-N+i);
Y0=A0*Uk_1;
e(k)=y(k-1)-Y0
(1);
Yr=zeros(P,1);
Yr(i)=yr;
Ek=zeros(P,1);
Ek(i)=e(k);
delta_u=inv(A'
*A+eye(M))*A'
*(Yr-Y0-Ek);
%���������ļ���
ifk+i-1<
u(k+i-1)=u(k+i-1-1)+delta_u(i);
%�����ɵļ���
temp=0;
%������k-j-1ʱ����ǰ�Ŀ�����
ifk-j<
temp;
ifk-j-1<
temp=temp+a(j)*u(k-j);
else
temp=temp+a(j)*(u(k-j)-u(k-j-1));
end
ifk-N<
y(k)=temp+e(N);
else
y(k)=temp+a(N)*u(k-N)+e(N);
%��ͼ��ʾ���
t=10*(1:
N);
subplot(211);
plot(t,y);
title('
DMC�����������'
xlabel('
t'
ylabel('
y'
gridon
subplot(212);
plot(t,u,'
r'
��������'
u'