Skip to main content

more options

Part 6: Loops      Part 8: Examples

Module 1, part 7. User-defined functions.


No. Topic Discussion
1. User defined functions   Blecture   pdf This blecture shows you how to define and call your own functions.
2. Examples

This set of four functions produces some graphics. Download the files and experiment with them!

The main function that calls the rest is dotsInCircles . To run this example, you can type dotsInCircles(200,4) in the Command Window. After seeing it run, you should read the function comment and choose your function arguments.

Look closely at the function headers and how they are called. This example includes functions with one output arguments, multiple output arguments, and no output arguments.

Make sure that you know how to call functions given a function header.

3. Executing a function Blecture   pdf This blecture shows you how a function executes and what happens in memory space.
4. Subfunctions
Read Chapman § 7.2.1
One m-file can contain multiple functions. This section shows you how to create subfunctions. Subfunctions are also called local functions.
5. Self-check exercise Practice defining your own functions and calling them from scripts or other functions