%  Logical select between functions  
function result = pick_fun(x,logic,trueFun,falseFun)
  result=zeros(size(x));
  indx=find(logic);
  if ~isempty(indx)
    result(indx)=trueFun(x(indx));
  end
  indx=find(~logic);
  if ~isempty(indx)
    result(indx)=falseFun(x(indx));
  end
end
