%  Logical select from arrays  
function result = iff(test,trueVal,falseVal)
  if size(test')==size(trueVal)
    test=test';
  elseif size(test')==size(falseVal)
    test=test';
  end
  [test,trueVal,falseVal]=MatchSize(test,trueVal,falseVal);
  result=zeros(size(test));
  indx=find(test);
  result(indx) = trueVal(indx);
  indx=find(~test);
  result(indx) = falseVal(indx);
end
