├── RBF1.m ├── RBF2.m ├── README.md ├── X_desired.m ├── actual_control.m ├── adaptive_neural_network.m ├── commond_filter.m ├── quantizer.m ├── system1.m ├── system2.m └── virtual_control.m /RBF1.m: -------------------------------------------------------------------------------- 1 | function [ gama,W,B_norm ] = RBF1(X1,Xd,Z,W_prev,gama_prev,dt) 2 | w_rate=3; 3 | w_sigma=0.01; 4 | gama_rate=1.5; 5 | gama_sigma=0.1; 6 | epsilon1=0.08; 7 | neurons=20; 8 | c1=linspace(-1,1,neurons); 9 | c2=linspace(-1,1,neurons); 10 | c3=linspace(-0.5,0.5,neurons); 11 | c4=linspace(-0.5,0.5,neurons); 12 | C=[c1;c2;c3;c4]; 13 | 14 | X=[X1;Xd]; 15 | sigma1=0.1; 16 | sigma2=0.05; 17 | S=[sigma1;sigma1;sigma2;sigma2]; 18 | B=zeros(4,neurons); 19 | for i=1:neurons 20 | B(:,i)=exp(-((X-C(:,i)).^2)./(2*(S).^2)); 21 | end 22 | 23 | B_norm=norm(B); 24 | Wdot=(w_rate*(norm(Z))^2*(B_norm)^2)-w_sigma*(norm(Z)^2)*W_prev; 25 | gamadot=gama_rate*((Z'*tanh(Z/epsilon1))-gama_sigma*norm(Z)*gama_prev); 26 | gama=gamadot*dt+gama_prev; 27 | W=Wdot*dt+W_prev; 28 | end 29 | 30 | -------------------------------------------------------------------------------- /RBF2.m: -------------------------------------------------------------------------------- 1 | function [gama2,W2,B2 ] = RBF2(X2,Z_prev,Beta_prev,Z,W_prev,gama_prev,dt) 2 | w_rate=3; 3 | w_sigma=0.01; 4 | gama_rate=1.5; 5 | gama_sigma=0.1; 6 | epsilon1=0.08; 7 | neurons=20; 8 | c1=linspace(-0.5,0.5,neurons); 9 | c2=linspace(-0.5,0.5,neurons); 10 | c3=linspace(-0.5,0.5,neurons); 11 | c4=linspace(-0.5,0.5,neurons); 12 | c5=linspace(-0.5,0.5,neurons); 13 | c6=linspace(-0.5,0.5,neurons); 14 | C=[c1;c2;c3;c4;c5;c6]; 15 | 16 | X=[X2;Z_prev;Beta_prev]; 17 | sigma1=0.05; 18 | sigma2=0.05; 19 | sigma3=0.05; 20 | S=[sigma1;sigma1;sigma2;sigma2;sigma3;sigma3]; 21 | B=zeros(6,neurons); 22 | for i=1:neurons 23 | B(:,i)=exp(-((X-C(:,i)).^2)./(2*(S).^2)); 24 | end 25 | 26 | B2=norm(B); 27 | Wdot=(w_rate*(norm(Z))^2*(B2)^2)-w_sigma*(norm(Z)^2)*W_prev; 28 | gamadot2=gama_rate*((Z'*tanh(Z/epsilon1))-gama_sigma*norm(Z)*gama_prev); 29 | gama2=gamadot2*dt+gama_prev; 30 | W2=Wdot*dt+W_prev; 31 | 32 | 33 | end 34 | 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Adaptive-Neural-Control-of-Uncertain-MIMO-Nonlinear-Pure-Feedback-Systems-via-Quantized-States 2 | this repository is a control system implemention in Matlab which is proposed by BYUNG MO KIM et al.(DOI:10.1109/ACCESS.2022.3165567) 3 | 4 | the study presented a neural network baskstepping control for nonlinear uncertain non_affine system with qunatized states. a neural network is applied to approximate nonlinear uncertain function. 5 | 6 | 7 | ![Signal-flow-graph-of-the-perceptron-A-single-perceptron-is-not-very-useful-because-of-its](https://user-images.githubusercontent.com/103693616/181631879-d8a7c81a-2442-4c7c-b9ac-8dc69251ca91.png) 8 | 9 | Note: 10 | the adaptive_neural_network.m is the main file including all other functions, so someone who interated in runing the codes,first put all files in a folder and run the adaptive_neural_network.m. there are two system functions for which the control system is investigated. 11 | 12 | Figs: 13 | ![fig1](https://user-images.githubusercontent.com/103693616/181641048-e5deb65c-c21d-44dc-adf1-40e0f9feb769.png) 14 | ![fig2](https://user-images.githubusercontent.com/103693616/181641044-6e270daa-4c2a-46c3-95cf-d797c82a4316.png) 15 | ![fig3](https://user-images.githubusercontent.com/103693616/181641042-1a084158-b941-48cb-80f4-2a4d470d1e88.png) 16 | ![fig4](https://user-images.githubusercontent.com/103693616/181641041-6481eafb-4236-4bf7-8f57-a136d8b40b72.png) 17 | ![fig5](https://user-images.githubusercontent.com/103693616/181641038-82894088-3f7c-42de-9f7a-0306447d7d55.png) 18 | ![fig6](https://user-images.githubusercontent.com/103693616/181641037-a7a7c951-08e7-4a27-a930-d9e718101943.png) 19 | ![fig7](https://user-images.githubusercontent.com/103693616/181641035-1da26d1e-aef4-4aa0-af97-f10d4965ecf0.png) 20 | ![fig8](https://user-images.githubusercontent.com/103693616/181641034-abc213e3-ba22-41c0-b483-3e7306069f83.png) 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /X_desired.m: -------------------------------------------------------------------------------- 1 | function [X_d,Xdot_d ] = X_desired(t) 2 | X_d=[-0.3*sin(0.5*t)+0.5*cos(0.25*t+pi/3);0.3*sin(0.5*t)+0.5*cos(0.25*t)]; 3 | Xdot_d=[-0.3*0.5*cos(0.5*t)-0.5*0.25*sin(0.25*t+pi/3);0.3*0.5*cos(0.5*t)-0.5*0.25*sin(0.25*t)]; 4 | 5 | end 6 | 7 | -------------------------------------------------------------------------------- /actual_control.m: -------------------------------------------------------------------------------- 1 | function u = actual_control( Z2,B2_norm,W2,gama2 ) 2 | kesi2=7; 3 | epsilon_hat=0.25; 4 | epsilon2=0.08; 5 | u=-(kesi2+1)*Z2-((Z2)/(Z2'*Z2+epsilon_hat))*B2_norm^2*W2-gama2*tanh(Z2/epsilon2); 6 | 7 | end 8 | 9 | -------------------------------------------------------------------------------- /adaptive_neural_network.m: -------------------------------------------------------------------------------- 1 | clc 2 | clear 3 | %% initilization 4 | 5 | X1_0=[0,0]'; 6 | X2_0=[0,0]'; 7 | dt=0.001; 8 | t=0:dt:30; 9 | X1=zeros(2,length(t)); 10 | X2=zeros(2,length(t)); 11 | 12 | U=zeros(2,length(t)); 13 | Xq11=zeros(size(t)); 14 | Xq12=zeros(size(t)); 15 | Xq21=zeros(size(t)); 16 | Xq22=zeros(size(t)); 17 | W1=zeros(size(t)); 18 | W1(1)=0.00; 19 | W2=zeros(size(t)); 20 | W2(1)=0.00; 21 | Gama1=zeros(size(t)); 22 | Gama1(1)=0.00; 23 | Gama2=zeros(size(t)); 24 | Gama2(1)=0.00; 25 | Alpha_IF=zeros(2,length(t)); 26 | Beta_IF=zeros(2,length(t)); 27 | X_d=zeros(2,length(t)); 28 | X_ddot=zeros(2,length(t)); 29 | Z1q=zeros(2,length(t)); 30 | for i=1:length(t)-1 31 | X_qun11=quantizer(X1(1,i),1,-1,500); 32 | X_qun12=quantizer(X1(2,i),1,-1,500); 33 | X_qun21=quantizer(X2(1,i),1,-1,500); 34 | X_qun22=quantizer(X2(2,i),1,-1,500); 35 | Xq11(i+1)=X_qun11; 36 | Xq12(i+1)=X_qun12; 37 | Xq21(i+1)=X_qun21; 38 | Xq22(i+1)=X_qun22; 39 | [x_d,xdot_d ] = X_desired(t(i)); 40 | X_d(:,i+1)=x_d; 41 | X_ddot(:,i+1)=xdot_d; 42 | X_1q=[Xq11(i);Xq12(i)]; 43 | Z1=X_1q-X_d(:,i); 44 | Z1q(:,i)=Z1; 45 | [ gama1,w1,B_norm1 ] = RBF1(X_1q,X_ddot(:,i),Z1,W1(i),Gama1(i),dt); 46 | W1(i+1)=w1; 47 | Gama1(i+1)=gama1; 48 | B1=B_norm1; 49 | alpha1 = virtual_control(Z1,B1,W1(i),Gama1(i)); 50 | if i==1 51 | Alpha_IF(:,1)=alpha1; 52 | end 53 | [ alpha_if,beta_if ] = commond_filter( alpha1,Beta_IF(:,i),Alpha_IF(:,i),dt ); 54 | Alpha_IF(:,i+1)=alpha_if; 55 | Beta_IF(:,i+1)=beta_if; 56 | X_2q=[Xq21(i);Xq22(i)]; 57 | Z2=X_2q-Alpha_IF(:,i); 58 | [gama2,w2,B_norm2 ] = RBF2(X_2q,Z1,Beta_IF(:,i),Z2,W2(i),Gama2(i),dt); 59 | W2(i+1)=w2; 60 | Gama2(i+1)=gama2; 61 | B2=B_norm2; 62 | u = actual_control( Z2,B2,W2(i),Gama2(i) ); 63 | U(:,i)=u; 64 | 65 | [X11,X21] =system2( X1(:,i),X2(:,i),U(:,i),t(i),dt); 66 | X1(:,i+1)=X11; 67 | X2(:,i+1)=X21; 68 | 69 | 70 | 71 | 72 | end 73 | figure(1) 74 | plot(t,Xq11(1,:),'r','LineWidth',2) 75 | hold on 76 | plot(t,X_d(1,:),'b','LineWidth',2) 77 | legend('y1','X1,d') 78 | xlabel('time') 79 | ylabel('y1 and X1,d') 80 | figure(2) 81 | plot(t,Xq12(1,:),'r','LineWidth',2) 82 | hold on 83 | plot(t,X_d(2,:),'b','LineWidth',2) 84 | legend('y2','X2,d') 85 | xlabel('time') 86 | ylabel('y2 and X2,d') 87 | figure(3) 88 | plot(t,Z1q(1,:),'r','LineWidth',2) 89 | legend('z1') 90 | xlabel('time') 91 | ylabel('z1') 92 | figure(4) 93 | plot(t,Z1q(2,:),'b','LineWidth',2) 94 | legend('z2') 95 | xlabel('time') 96 | ylabel('z2') 97 | figure(5) 98 | plot(t,U(1,:),'b','LineWidth',2) 99 | legend('u1') 100 | xlabel('time') 101 | ylabel('u1') 102 | figure(6) 103 | plot(t,U(2,:),'b','LineWidth',2) 104 | legend('u2') 105 | xlabel('time') 106 | ylabel('u2') 107 | figure(7) 108 | plot(t,W1,'b','LineWidth',2) 109 | hold on 110 | plot(t,W2,'r','LineWidth',2) 111 | legend('W1','W2') 112 | xlabel('time') 113 | ylabel('W1,W2') 114 | figure(8) 115 | plot(t,Gama1,'b','LineWidth',2) 116 | hold on 117 | plot(t,Gama2,'r','LineWidth',2) 118 | legend('gama1','gama2') 119 | xlabel('time') 120 | ylabel('gama1,gama2') 121 | -------------------------------------------------------------------------------- /commond_filter.m: -------------------------------------------------------------------------------- 1 | function [ alpha_if,beta_if ] = commond_filter( alpha1,beta_if_prev,alpha_if_prev,dt ) 2 | taw=[0.707;0.707]; 3 | RO=[80;80]; 4 | alpha_if_dot=beta_if_prev; 5 | betha_ifdot=-2*taw'*RO*beta_if_prev-RO'*RO*(alpha_if_prev-alpha1); 6 | alpha_if=alpha_if_dot*dt+alpha_if_prev; 7 | beta_if=betha_ifdot*dt+beta_if_prev; 8 | 9 | end 10 | 11 | -------------------------------------------------------------------------------- /quantizer.m: -------------------------------------------------------------------------------- 1 | function signal = quantizer( signal,min,max,levels ) 2 | scalingFactor = (max-min)/levels; 3 | signal = signal/ scalingFactor; 4 | signal = round(signal); 5 | signal = signal * scalingFactor; 6 | 7 | end -------------------------------------------------------------------------------- /system1.m: -------------------------------------------------------------------------------- 1 | function [ X1,X2 ] = system1( X1_prev,X2_prev,U,t,dt) 2 | m1=1.5; 3 | m2=1.2; 4 | g=9.8; 5 | Lp=0.4; 6 | J1=m1*Lp^2; 7 | J2=m2*Lp^2; 8 | D=0.3; 9 | Sc=45; 10 | Sl=0.5; 11 | K=D^2+D*Lp*(sin(X1_prev(1))-sin(X1_prev(2)))+((Lp^2)/2)*(1-cos(X1_prev(2)-X1_prev(1))); 12 | Ld=sqrt(K); 13 | T=(0.5*Lp*(cos(X1_prev(2))-cos(X1_prev(1))))/(D+0.5*Lp*(sin(X1_prev(1))-sin(X1_prev(2)))); 14 | theta0=atan(T); 15 | f11=X2_prev(1)+0.3*cos((X1_prev(1)^2)*X1_prev(2))*X2_prev(1); 16 | f12=X2_prev(2)+0.2*sin(X1_prev(1)*X1_prev(2))*X2_prev(2); 17 | deltaf21=(1/J1)*((0.2+0.1*cos(X1_prev(1)*X1_prev(2)))*U(1)); 18 | f21=(1/J1)*((m1*g*Lp*sin(X1_prev(1)))-0.5*Sc*Lp*cos(X1_prev(1)-theta0)*(Ld-Sl)+U(1))+deltaf21; 19 | deltaf22=(1/J2)*((0.2+0.1*cos(X2_prev(1)*X2_prev(2)))*U(2)); 20 | f22=(1/J2)*((m2*g*Lp*sin(X1_prev(2)))-0.5*Sc*Lp*cos(X1_prev(2)-theta0)*(Ld-Sl)+U(2))+deltaf22; 21 | d11=0.1*cos(2*t); 22 | d12=0.1*sin(2*t); 23 | d21=0.2*sin(t); 24 | d22=0.2*cos(t); 25 | F1=[f11,f12]'; 26 | D1=[d11,d12]'; 27 | F2=[f21,f22]'; 28 | D2=[d21,d22]'; 29 | 30 | Xdot1=F1+D1; 31 | Xdot2=F2+D2; 32 | 33 | X1=Xdot1*dt+X1_prev; 34 | X2=Xdot2*dt+X2_prev; 35 | 36 | 37 | 38 | end 39 | 40 | -------------------------------------------------------------------------------- /system2.m: -------------------------------------------------------------------------------- 1 | function [ X1,X2 ] = system2( X1_prev,X2_prev,U,t,dt) 2 | f11=(4+sin(X1_prev(1)*X1_prev(2)))*X2_prev(1)+0.3*cos(X2_prev(1)); 3 | f12=(2+sin(X1_prev(1)*X1_prev(2)))*X2_prev(2)+0.7*sin(X2_prev(2)); 4 | f21=X2_prev(2)*exp(-X1_prev(1)*(X2_prev(1))^2)+(2+(X1_prev(2))^2)*U(1)+0.5*cos(U(1)); 5 | f22=X1_prev(2)*exp(-X2_prev(1)*(X1_prev(2))^2)+(3+(X1_prev(1))^2)*U(2)+0.3*sin(U(2)); 6 | d11=0.15*cos(0.5*t); 7 | d12=0.15*sin(0.5*t); 8 | d21=0.1*cos(t); 9 | d22=0.1*sin(t); 10 | F1=[f11,f12]'; 11 | D1=[d11,d12]'; 12 | F2=[f21,f22]'; 13 | D2=[d21,d22]'; 14 | 15 | Xdot1=F1+D1; 16 | Xdot2=F2+D2; 17 | 18 | X1=Xdot1*dt+X1_prev; 19 | X2=Xdot2*dt+X2_prev; 20 | 21 | 22 | 23 | end 24 | 25 | -------------------------------------------------------------------------------- /virtual_control.m: -------------------------------------------------------------------------------- 1 | function alpha1 = virtual_control(Z,B,W1,gama1) 2 | kesi1=5; 3 | epsilon_hat=0.25; 4 | epsilon=0.08; 5 | alpha1=-(kesi1+1)*Z-((Z)/(Z'*Z+epsilon_hat))*B^2*W1-gama1*tanh(Z/epsilon); 6 | end 7 | 8 | --------------------------------------------------------------------------------