您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > AI人工智能 > 智能控制(神经网络)-作业
智能控制作业学生姓名:学号:专业班级:7-2采用BP网路、RBF网路、DRNN网路逼近线性对象2)1(1)1(9.0)1()(kykykuky,分别进行matlab仿真。(一)采用BP网络仿真网络结构为2-6-1。采样时间1ms,输入信号)6sin(5.0)(tku,权值21,WW的初值随机取值,05.0,05.0。仿真m文件程序为:%BPsimulationclearall;clearall;xite=0.5;alfa=0.5;w1=rands(2,6);%valueofw1,initiallybyrandomw1_1=w1;w1_2=w1;w2=rands(6,1);%valueofw2,initiallybyrandomw2_1=w2;w2_2=w2_1;dw1=0*w1;x=[0,0]';u_1=0;y_1=0;I=[0,0,0,0,0,0]';%inputofyinhancengcellIout=[0,0,0,0,0,0]';%outputofyinhancengcellFI=[0,0,0,0,0,0]';ts=0.001;fork=1:1:1000time(k)=k*ts;u(k)=0.5*sin(3*2*pi*k*ts);y(k)=(u_1-0.9*y_1)/(1+y_1^2);forj=1:1:6I(j)=x'*w1(:,j);Iout(j)=1/(1+exp(-I(j)));endyn(k)=w2'*Iout;%outputofnetworke(k)=y(k)-yn(k);%errorcalculationw2=w2_1+(xite*e(k))*Iout+alfa*(w2_1-w2_2);%rectifyofw2forj=1:1:6FI(j)=exp(-I(j))/(1+exp(-I(j))^2);endfori=1:1:2forj=1:1:6dw1(i,j)=e(k)*xite*FI(j)*w2(j)*x(i);%dw1calculationendendw1=w1_1+dw1+alfa*(w1_1-w1_2);%rectifyofw1%jacobianinformationyu=0;forj=1:1:6yu=yu+w2(j)*w1(1,j)*FI(j);enddyu(k)=yu;x(1)=u(k);x(2)=y(k);w1_2=w1_1;w1_1=w1;w2_2=w2_1;w2_1=w2;u_1=u(k);y_1=y(k);endfigure(1);plot(time,y,'r',time,yn,'b');xlabel('times');ylabel('yandyn');figure(2);plot(time,y-yn,'r');xlabel('times');ylabel('error');figure(3);plot(time,dyu);xlabel('times');ylabel('dyu');运行结果为:(二)采用RBF网络仿真网路结构为2-4-1,采样时间1ms,输入信号)2sin(5.0)(tku,权值的初值随机取值,05.0,05.0,高斯基函数初值TjC]5.0,5.0[,TB]5.1,5.1,5.1,5.1[。仿真m文件程序如下:%RBFsimulationclearallclearallalfa=0.05;xite=0.5;x=[0,0]';b=1.5*ones(4,1);c=0.5*ones(2,4);w=rands(4,1);w_1=w;w_2=w_1;c_1=c;c_2=c_1;b_1=b;b_2=b_1d_w=0*w;d_b=0*b;y_1=0;ts=0.001;fork=1:1:2000;time(k)=k*ts;u(k)=0.5*sin(1*2*pi*k*ts);y(k)=(u(k)-0.9*y_1)/(1+y_1^2);x(1)=u(k);x(2)=y_1;forj=1:1:4h(j)=exp(-norm(x-c(:,j))^2/(2*b(j)*b(j)));endym(k)=w'*h';em(k)=y(k)-ym(k);forj=1:1:4d_w(j)=xite*em(k)*h(j);d_b(j)=xite*em(k)*w(j)*h(j)*(b(j)^-3)*norm(x-c(:,j))^2;fori=1:1:2d_c(i,j)=xite*em(k)*w(j)*h(j)*(x(i)-c(i,j))*(b(j)^-2);endendw=w_1+d_w+alfa*(w_1-w_1);b=b_1+d_b+alfa*(b_1-b_2);c=c_1+d_c+alfa*(c_1-c_2);%Jacobianinformationyu=0;forj=1:1:4yu=yu+w(j)*h(j)*(c(1,j)-x(1))/b(j)^2;enddyu(k)=yu;y_1=y(k);w_2=w_1;w_1=w;c_2=c_1;c_1=c;b_2=b_1;b_1=b;endfigure(1);plot(time,y,'r',time,ym,'b');xlabel('time(s)');ylabel('yandym');figure(2);plot(time,y-ym,'r');xlabel('time(s)');ylabel('error');figure(3);plot(time,dyu,'b');xlabel('time(s)');ylabel('dyu');仿真结果为:(三)DRNN网路仿真采样时间1ms,输入信号)4sin(5.0)(tku,权值IOD的初值随机取值,取35.0,35.0,35.0IDO。仿真m文件程序为:%DRNNsimulationclearall;clearall;wd=rands(7,1);wo=rands(7,1);wi=rands(3,7);xj=zeros(7,1);xj_1=xj;u_1=0;y_1=0;xitei=0.35;xited=0.35;xiteo=0.35;ts=0.001;fork=1:1:1000time(k)=k*ts;u(k)=0.5*sin(4*pi*k*ts);y(k)=(u_1-0.9*y_1)/(1+y_1^2);Ini=[u_1,y_1,1]';forj=1:1:7sj(j)=Ini'*wi(:,j)+wd(j)*xj(j);endforj=1:1:7xj(j)=(1-exp(-sj(j)))/(1+exp(-sj(j)));endPj=0*xj;forj=1:1:7Pj=wo(j)*(1+xj(j))*(1-xj(j))*xj_1(j);endQij=0*wi;forj=1:1:7fori=1:1:3Qij(i,j)=wo(j)*(1+xj(j))*(1-xj(j))*Ini(i);endendymk=0;forj=1:1:7ymk=ymk+xj(j)*wo(j);endym(k)=ymk;e(k)=y(k)-ym(k);wo=wo+xiteo*e(k)*xj;wd=wd+xited*e(k)*Pj;wi=wi+xitei*e(k)*Qij;xj_1=xj;u_1=u(k);y_1=y(k);endfigure(1);plot(time,y,'r',time,ym,'b');xlabel('time/s');ylabel('yandym');figure(2);plot(time,y-ym,'r');xlabel('time/s');ylabel('error');仿真结果为:
本文标题:智能控制(神经网络)-作业
链接地址:https://www.777doc.com/doc-4339741 .html