Functions > Utility Functions > Conditional Branching
Conditional Branching
if(cond, x, y)—Returns x if cond is true (nonzero), y otherwise.
Only the necessary arguments of if are evaluated. If cond is true, y is not evaluated, and if cond is false, x is not evaluated. Errors in x and y may go undetected this way.
if is a PTC Mathcad control operator, not a function, and it does not work with operators that modify functions, such as the vectorize operator.
Arguments
cond is an expression, typically involving a Boolean operator.
x, y are arbitrary numbers, arrays, or strings, or functions that evaluate to one of these.
Was this helpful?