%%%%%%多入多出闭环PD迭代学习控制
%PID type learning control
clear all;
close all;
t=[0:0.01:20]';%设置仿真时间20s
k(1:301)=0; %总共301个点
k=k';
T1(1:301)=0; %控制系统输入,共两个输入都为列向量
T1=T1';
T2=T1;
T=[T1 T2];
k1(1:301)=0; %Total initial points k1变量的第1个到301个元素全部赋为0
k1=k1'; %k1为列向量
E1(1:301)=0;
E1=E1';
E2=E1;%E2,E3,E4全为列向量
E3=E1;
E4=E1;
E=[E1 E2 E3 E4];%用来保存两个信号的误差和误差的导数项
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
M=20;%%%%%%%%%%最大迭代次数,可以修改
for i=0:1:M % M迭代次数
i; %在命令窗口显示迭代了多少了
pause(0.01);
sim('chap6_2sim',[0,20]);%%simulink仿真
x1=x(:,1);%%%迭代后输出
x2=x(:,2);
x3=x(:,3);
x4=x(:,4);
x1d=xd(:,1);%%%%%两个期望值和各自的导数项存放在xd中
x2d=xd(:,2);
dx1d=xd(:,3);
dx2d=xd(:,4);
e1=E(:,1);%%%%误差和误差导数放在E中
e2=E(:,2);
de1=E(:,3);
de2=E(:,4);
e=[e1 e2]';
de=[de1 de2]';
figure(1);
subplot(211);
plot(t,xd(:,1),'r',t,x(:,1),'k:','linewidth',2);%x(:,1)期望的角度,x(:,5)跟踪的角度
xlabel('time(s)');ylabel('Position tracking for hip');
legend('ideal position for hip','position tracking for hip');%髋关节的角度跟踪
subplot(212);
plot(t,xd(:,2),'r',t,x(:,2),'k:','linewidth',2);
xlabel('time(s)');ylabel('Position tracking for knee');
legend('ideal position for knee','position tracking for knee');%膝关节的角度跟踪
figure(2);
subplot(211);
plot(t,xd(:,3),'r',t,x(:,3),'k:','linewidth',2);%x(:,3)期望的角速度,x(:,6)跟踪的角速度
xlabel('time(s)');ylabel('Speed tracking for hip');
legend('ideal speed for hip','speed tracking for hip');%髋关节的速度跟踪
subplot(212);
plot(t,xd(:,4),'r',t,x(:,4),'k:','linewidth',2);
xlabel('time(s)');ylabel('Speed tracking for knee');
legend('ideal speed for knee','speed tracking for knee');%膝关节的速度跟踪
j=i+1;
times(j)=i;%%%%迭代的次数用数组表示 便于绘制迭代次数和误差的曲线
e1i(j)=max(abs(e1));
e2i(j)=max(abs(e2));
de1i(j)=max(abs(de1));
de2i(j)=max(abs(de2));
end %迭代过程结束
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure(3);
subplot(211);
plot(t,Tol(:,1),'r','linewidth',2);
xlabel('time(s)');ylabel('Control input of hip');%髋关节的控制输入
subplot(212);
plot(t,Tol(:,1),'r','linewidth',2);
xlabel('time(s)');ylabel('Control input of knee');%膝关节的控制输入
figure(4);
subplot(211);
plot(t,f(:,1),'r',t,f(:,2),'k:','linewidth',2);%f(:,1)实际不确定性,f(:,2)估计不确定性
xlabel('time(s)');ylabel('f1 and fn1');
legend('Practical uncertainties of hip','Estimation uncertainties of hip');%髋关节的实际不确定性与髋关节的估计不确定性
subplot(212);
plot(t,f(:,3),'r',t,f(:,4),'k:','linewidth',2);%f(:,3)实际不确定性,f(:,4)估计不确定性
xlabel('time(s)');ylabel('f2 and fn2');
legend('Practical uncertainties of knee','Estimation uncertainties of knee');%膝关节的实际不确定性与膝关节的估计不确定性
% figure(5);
% subplot(211);
% plot(t,qd1,'r',t,q1,'b:','linewidth',2);
% xlabel('time(s)');ylabel('Angle tracking tracking of hip');
% subplot(212);
% plot(t,qd2,'r',t,q2,'b:','linewidth',2);
% xlabel('time(s)');ylabel('Angle tracking tracking of knee');
%
% figure(6);
% subplot(211);
% plot(t,dqd1,'r',t,qd1,'b:','linewidth',2);
% xlabel('time(s)');ylabel('Angle speed tracking tracking of hip');
% subplot(212);
% plot(t,dqd2,'r',t,qd2,'b:','linewidth',2);
% xlabel('time(s)');ylabel('Angle speed tracking tracking of knee');
figure(7);
subplot(211);%%%%绘制误差与迭代次数的关系
plot(times,e1i,'*-r',times,e2i,'o- b','linewidth',2);
title('The maximum absolute value of error with the number of iterations');%最大绝对值误差随迭代次数的变化
xlabel('The number of iterations');ylabel('error1 and error2');
subplot(212);
plot(times,de1i,'*-r',times,de2i,'o- b','linewidth',2);
title('The maximum absolute value of error with the number of iterations');%最大绝对值误差的变化率随迭代次数的变化
xlabel('The number of iterations');ylabel('error1 and error2');
没有合适的资源?快使用搜索试试~ 我知道了~
RBF神经网络matlab代码.zip
共32个文件
m:24个
mdl:7个
r2007b:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 15 浏览量
2024-03-03
17:33:17
上传
评论
收藏 76KB ZIP 举报
温馨提示
1.版本:matlab2014/2019a/2021a 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程、数学等专业的大学生课程设计、期末大作业和毕业设计。
资源推荐
资源详情
资源评论
收起资源包目录
RBF神经网络matlab代码.zip (32个子文件)
RBF神经网络matlab代码
chap6_2sim.mdl 44KB
chap6_2sim.mdl.r2007b 22KB
chap6_2ctrl.m 4KB
chap6_2plant.m 2KB
chap6_2input.m 831B
chap6_2plot.m 4KB
chap6
chap6_5plant.m 776B
chap6_3sim.mdl 21KB
chap6_4plant.m 3KB
chap6_1plot.m 497B
chap6_5plot.m 812B
chap6_2sim.mdl 22KB
chap6_3plant.m 745B
chap6_3plot.m 497B
chap6_6sim.mdl 21KB
chap6_2ctrl.m 3KB
chap6_6ctrl.m 2KB
chap6_6plot.m 1KB
chap6_2plant.m 2KB
chap6_4input.m 1KB
chap6_6plant.m 1KB
chap6_1sim.mdl 21KB
chap6_2input.m 777B
chap6_4ctrl.m 2KB
chap6_4plot.m 1KB
chap6_2plot.m 1KB
chap6_5ctrl.m 1KB
chap6_4sim.mdl 21KB
chap6_1plant.m 744B
chap6_1ctrl.m 2KB
chap6_5sim.mdl 20KB
chap6_3ctrl.m 1KB
共 32 条
- 1
资源评论
matlab科研助手
- 粉丝: 1w+
- 资源: 1908
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功