function out = membership(m,x)
%MEMBERSHIP Compute the degree of fullfilment of the rules
%    of a mamdani function
%    
%    OUT = MEMBERSHIP(M,X) %
%    
%    See also: 
%    
%    

%MAN_PAGE_BEGIN
%
%   @purpose	Compute the degree of fullfilment of the rules of a mamdani function.
%
%   @synopsis	out = membership(m,x)
%   @description  
%%
%   @see 
%
%MAN_PAGE_END


ni = get(m,'n_in');
and_code=m.model_code{1};

for i=1:ni,
	mg(:,:,i) = mgrade(x(:,i), m.mfs{i}(m.rls(:,i),:));
end

if and_code == 'product',
	out = prod(mg,3)';
end
