-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathERROR_Fuzzy.m
37 lines (31 loc) · 905 Bytes
/
ERROR_Fuzzy.m
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
function dERROR = ERROR_Fuzzy(t,ERROR,Simu)
A = Simu.controller.model.A;
B = Simu.controller.model.B;
trajectory = Simu.trajectory;
[q_d,dq_d,~]=CalcDesTrajectory(trajectory,t);
DES_STATE = [dq_d;q_d];
Psi = ERROR(8)+ DES_STATE(8);
h = Simu.controller.model.h;
h = subs(h,'psi',Psi);
h = double(h);
STATE = ERROR + DES_STATE;
V = CalcVirtControlLaw(Simu.controller,t,STATE,DES_STATE);
if(Simu.controller.model.type == 2)
Ah = 0*A{1,1};
Bh = 0*B{1};
for i=1:length(h)
for j = 1:length(h)
Ah=Ah+h(i)*h(j)*A{i,j};
end
Bh=Bh+h(i)*B{i};
end
else
Ah = 0*A{1};
Bh = 0*B{1};
for i=1:length(h)
Ah=Ah+h(i)*A{i};
Bh=Bh+h(i)*B{i};
end
end
dERROR = Ah*ERROR + Bh*V;
end