If a function does not alter an argument but simply uses it in a computation, MATLAB passes
the argument by reference to optimize memory use. This implies that even if the function modi-
fies the input arguments, it will not affect the original data in the invoking code as illustrated in
Example 5.5.
Time for Practice 5.4
Consider the evaluation of the function
log
1
1−
x
. When x≥ 1 the argument will be non-
positive and “invalid”. Create a function invlog.m using an if-construct that will evaluate the
function and print either its value or an error message indicating the message that the input ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.