%	farc_FUZZIFIER.M
%
%	Fuzzify inputs 
%	(needs 'farc_1.mdl', 'af_input_gen.m', 'frac1f_update.m')

function xi = farc_fuzzifer(x)  % x(1): x  x(2): x'

% Define membership functions

x1N=min(1,max(0,1-(x(1)+2)/4));
x1P=min(1,max(0,1+(x(1)-2)/4));

x2NB=min(1,max(0,1-(x(2)+20)/19));
x2NS=max(0,min(1+(x(2)+1)/19,1-(x(2)+1)/.65));
x2NVS=max(0,min(1+(x(2)+.35)/.65,1-(x(2)+.35)/.7));
x2PVS=max(0,min(1+(x(2)-.35)/.7,1-(x(2)-.35)/.65));
x2PS=max(0,min(1+(x(2)-1)/.65,1-(x(2)-1)/19));
x2PB=min(1,max(0,1+(x(2)-20)/19));


% Xi

b =[
   x1N*x2NB
   x1N*x2NS
   x1N*x2NVS
   x1N*x2PVS
   x1N*x2PS
   x1N*x2PB
   
   x1P*x2NB
   x1P*x2NS
   x1P*x2NVS
   x1P*x2PVS
   x1P*x2PS
   x1P*x2PB];
   
xi=b/sum(b);




   		
