资源简介
对于双输入双输出系统的模型预测控制(DMC)的MATLAB实现,能直接运行得到结论,是学习DMC的一个较好的资源。
代码片段和文件信息
clear;
clc;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%基础参数设置
delt=1;%采样周期
N=150; %模型长度
p=2;m=2; %系统维数-2输入2输出
t=0:delt:delt*N;
P=10;%优化时域
M=5; %控制时域
nn=N/delt+1; %在线计算步数
%输出误差加权系数-单位阵
ramena_y=1;q=ramena_y*eye(P);
%控制加权系数-对角线元素为0.02的对角阵
ramena_u=0.02;r=ramena_u*eye(M);
rd=0;%扰动
%传递函数建立
sys11=tf(0.35[500 45 1]‘inputdelay‘1);
sys12=tf(0.50[150 25 1]‘inputdelay‘2.5);
sys21=tf(0.85[2000 90 1]‘inputdelay‘2);
sys22=tf(-0.90[1200 70 1]‘inputdelay‘1);
%建立阶跃响应模型
[y11t11x11]=step(sys11t);model{11}=y11(1:N);
[y12t12x12]=step(sys12t);model{12}=y12(1:N);
[y21t21x21]=step(sys21t);model{21}=y21(1:N);
[y22t22x22]=step(sys22t);model{22}=y22(1:N);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%模型预测
%建立动态响应矩阵 A
for i=1:p
for j=1:m %对 p*m 个优化变量赋值
for i1=1:M
for i2=1:P
if i2 B{ij}(i2i1)=0; %超出控制时域时,控制增量无变化
else
B{ij}(i2i1)=model{ij}(i2-i1+1);%未超出时赋值为对应的阶跃响应系数
end
end
end
end
C{i}=cat(2B{i1:m}); %联结为动态响应矩阵的行数
end
A=cat(1C{1:p});
%按列连接为动态响应矩阵 由阶跃响应系数组成的 P*M阵
%{}中下标 i 表示所预测未来输出的个数,下标 j 表示控制量变化的次数
for i=1:p
aa{i}=cat(2model{i1:m});
end
A0=cat(1aa{1:p});
ym=zeros(p*N1);
y=zeros(nnp);
du=zeros(m1);
uu=zeros(m1);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%滚动优化
%求控制向量 dT(由 Q R P M 四个参数确定)
for i=1:p
qq{i}=q;
end
Q=blkdiag(qq{1:p});
for i=1:m
rr{i}=r;
end
R=blkdiag(rr{1:m});
L=zeros(mm*M);
for i=1:m
L(iM*(i-1)+1)=1;
end
D=L*inv(A‘*Q*A+R)*A‘*Q; %控制向量计算公式
sp1=1;sp2=1;%预测输出设定值 可调整分别不一样
w{1}=sp1*ones(P1);
w{2}=sp2*ones(P1);
W=cat(1w{1:p});
%输出期望值
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%反馈校正
%建立矩阵HhstSS0
hst=ones(N1);
for i=1:p
hh{i}=hst;
end
H=blkdiag(hh{1:p});
ss=zeros(pp*N);
for i=1:m
ss(iN*(i-1)+1)=1;
end
S=zeros(N);
for i=1:N
for j=1:N
if j==i+1
S(ij)=1;
end
end
end
S(NN)=1;
for i=1:p
s{i}=S;
end
S0=blkdiag(s{1:p});
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%在线计算初始状态设置
u1_1=0;u1_2=0;
u2_1=0;u2_2=0;
y1_1=0;y1_2=0;y1_3=0;y1_4=0;
y2_1=0;y2_2=0;
y3_1=0;y3_2=0;
y4_1=0;y4_2=0;
u1=0;u2=0;
z11=c2d(sys110.5*delt‘zoh‘);
[num1den1]=tfdata(z11‘v‘);
z12=c2d(sys120.5*delt‘zoh‘);
[num2den2]=tfdata(z12‘v‘);
z21=c2d(sys210.5*delt‘zoh‘);
[num3den3]=tfdata(z21‘v‘);
z22=c2d(sys220.5*delt‘zoh‘);
[num4den4]=tfdata(z22‘v‘);
%在线计算
for k=1:nn
y111=num1(1)*u1+num1(2)*u1_
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2134489 2019-06-21 16:14 DMC_ttf_huitudou.pdf
文件 4599 2019-06-21 20:34 DMC.m
----------- --------- ---------- ----- ----
2139088 2
- 上一篇:自适应差分阈值法检测QRS波
- 下一篇:最新MATLAB分布式仿真平台搭建官方文档
相关资源
- Pattern Recognition and Machine Learning(高清
- MATLAB 编程 第二版 Stephen J. Chapman 著
- 均值滤波和FFT频谱分析Matlab代码
- 《MATLAB扩展编程》代码
- HDB3码、AMI码的MATLAB实现
- 3点GPS定位MATLAB仿真
- MATLAB数字信号处理85个实用案例精讲入
- matlab从入门到精通pdf94795
- 欧拉放大论文及matlab代码
- 跳一跳辅助_matlab版本
- 全面详解LTE MATLAB建模、仿真与实现
- MIMO-OFDM无线通信技术及MATLAB实现_孙锴
- MATLAB Programming for Engineers 4th - Chapman
- matlab 各种谱分析对比
- 分数阶chen混沌matlab程序
- 基于粒子群算法的非合作博弈的matl
- MATLAB车流仿真 包括跟驰、延误
- matlab空间桁架计算程序
- 基于MATLAB的图像特征点匹配和筛选
- DMA-TVP-FAVAR
- GPS信号的码捕获matlab代码.7z
- 一维光子晶体MATLAB仿真代码吸收率折
- newmark法源程序
- 传统关联成像、计算鬼成像matlab
- pri传统分选算法
- 摆动滚子推杆盘形凸轮设计
- 医学图像重建作业matlab源码
- Matlab实现混沌系统的控制
- 检测疲劳驾驶
- Matlab锁相环仿真-Phase Locked Loop.rar
评论
共有 条评论