forked from ikelq/AFF-RBFNN-Control-with-the-DPE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapproximation_performance_optimized.m
More file actions
116 lines (84 loc) · 2.14 KB
/
approximation_performance_optimized.m
File metadata and controls
116 lines (84 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
%% code of paper "Adaptive Feedforward RBF Neural Network Control with
%the Deterministic Persistence of Excitation"
%Authors: Qiong Liu Dongyu Li
% The details can be seen in the section "Structure Design of RBFNN with a Deterministic PELevel"
%% just show the approximation performance
clear
clc
close all
%% begin simulation
T=1000;
size=0.01;
t=0:size:T;
nt=length(t);
xd1=sin(t);
xd2=cos(t);
xdd2=-sin(t);
%%RBFNN
gamma=10; % for updating Weight
% width1=0.4;
width1=0.8;
% find the effective hidden node
ZZ=[xd1;xd2];
% SS1=zeros(Nodeu,1);
% for i=1:length(ZZ)
% SS=RBF(ZZ(:,i),Muu,width1,Nodeu);
% SS1=max(SS1,SS);
% end
% in=find(SS1>0.7);
% Mu=Muu(:,in);
% Node=length(Mu);
% save('hidden_node1','Mu')
load('hidden_node2');
Node=length(Mu);
PE=zeros(Node);
for i=1:2*pi*100+2
SS2(:,i)=RBF(ZZ(:,i),Mu,width1,Node);
ts(i)=i*0.01;
PE=PE+ 0.01*SS2(:,i)*SS2(:,i)';
end
% plot(ts,SS2)
minl=eig(PE)
min(minl)
% figure
% plot(ZZ(1,:)',ZZ(2,:))
% hold on
% plot(Mu(1,:)',Mu(2,:)','*','linewidth',1)
% xlabel('q_{1d}')
% ylabel('q_{2d}')
% print('D:\GE\robot control\06-Adaptive Feedforward RBF Neural-Network Learning Control\nodes2',...
% '-depsc', '-painters','-r600')
Mu5=Mu';
for i=1:length(Mu5)
for j=1:length(Mu5)
dis_Mu(i,j)=(Mu5(i,:)-Mu5(j,:))*(Mu5(i,:)-Mu5(j,:))';
end
end
W=zeros(Node,1);
WW(:,1)=W;
dw=zeros(Node,1);
dwf=dw;
normW=zeros(1,length(t));
dxd2=0;
dx2=0;
%% the first step
for i=2:nt
Z=[xd1(i-1);xd2(i-1)];
S=RBF(Z,Mu,width1,Node ); % RBF method is used in calculating S
normS(i)=norm(S);
F = -xd1(i-1)+ 0.7*(1-xd1(i-1)^2)*xd2(i-1);
r= F - W'*S;
dw= gamma*S*r; % updating law as stated
ee_appro(i)=r;
tt=(i-1)*size;
xd2(i)=cos(tt);
xd1(i)=sin(tt);
dxd2=-sin(tt);
W=dw*size+W; % Weights for next iteration
Norm_W1(i)=sqrt(W'*W); % Norm W1 & W2
WW(:,i)=W;
end
save("approximation_optimized",'ee_appro')
figure
plot(t,ee_appro)
stable_error = max ( ee_appro(:,length(t)-1000:length(t)) )