%  FARCg_update.M
%
%	Calculate adapation rate 


function rate = farcg_update(x)

% x(1)~x(12) : Xi    x(13)~x(24) : theta_g  
% x(25) : u_a        x(26) : sigma 

rate = zeros(12,1);
r = 5000;				%adatpation gain(learning rate)
theta_lb = 50;
theta_ub = 150;

for i = 1:12;
   alpha = r*x(26)*x(i)*x(25);
   rate(i)= alpha*(((x(i+12)>theta_lb)|(alpha>0))*((x(i+12)<theta_ub)|(alpha<0)));
end;