Form the top of the page you linked to:
This example is a function with the main body at the top and helper routines in the form of nested functions below.
In other words the readFrame
function is meant to be a nested function inside of the function where you create your obj.reader
object. Alternatively, you could pass in obj.reader
as an argument. If you look at the code that generated the obj.reader
object (setupSystemObjects
), it is also a nested function, but it returns obj
to the outer main function. By the way, if you want to view all of the code together in the Matlab editor, just type edit multiObjectTracking
in command window.
Nested functions have access to all of the variables (workspace) of the outer function. This blog post discusses them in more detail.