function z=trim(x,c)
%function z=trim(x,p)
%trims proportion p of largest values of x
%z=sort(x);
%z=z(floor((1-p)*length(x)));
%z=min(x,z);
%trims at the constant +-c
z=max(min(x,c),-c);