Here is an example of defining a class with a function that returns an optional variable:
main.m209 chars12 lines
This class has one method, myFunction
, which takes an input variable in
and returns an output variable out
. If in
is greater than zero, the function returns the square root of in
. Otherwise, it returns an empty matrix []
.
To create an instance of the MyClass
class and call the myFunction
method, you can do the following:
main.m248 chars9 lines
In this example, result1
will be 4, and result2
will be an empty matrix []
.
gistlibby LogSnag