I'm using Octave, a programming language similar to MATLAB, and I would like to invert every value in a particular matrix.
But if I tell it to use the function f(x) = 1/x, it will display an error when x=0.
Is there a well-known mathematical function (preferably that Octave has code for) that is equivalent to f(x) = 0 for x=0 and 1/x otherwise?
I'm relatively new to stack exchange, so please let me know how to improve my answer (or improve it by editing it, especially through adding LATEX).
Some computer languages have a
zidz(a, b)(=zero if divide by zero) function that returns $0$ ifb = 0anda/botherwise. The function you want would be a special case,zidz(1, x). Octave doesn't have this as a built-in function, but you can write one simply enough.