function y = trap_a(x,a1,a2,c,s)
%TRAP_A is an asymmetric trapezoid type membership function,
% also called a ``pi'' function,
% where x is the function domain, a1 is the length of the left trapezoid's side
% at the base, a2 is the length of the right side at the base,
% c is the trapezoid's center, and s is a half of the
% trapezoid upper side. Thus the length of the trapezoid upper
% side is 2*s. The length of the trapezoid base is then 2*s+a1+a2.
% Set s=0 to get a triangular membership function.

% Written by S. H. Zak

y1=min(0.5,(max((-0.5),(0.5 +((x-c+s)./a1)))));
y2=min(0.5,(max((-0.5),(0.5 -((x-c-s)./a2)))));
y=y1+y2;
