Functions
- Function files. A function lives in its own file with its own workspace: inputs in, outputs out, nothing shared.
- Local functions. Local functions share a file with their caller: helpers scoped where they serve.
- Anonymous functions. An anonymous function captures inline: f = @(x) x.^2: behaviour as a value.
Inputs and Outputs
- Multiple outputs. Functions return multiple outputs: [m, idx] = max(data): callers taking what they need.
- arguments blocks. The arguments block validates inputs declaratively: types, sizes and defaults checked at the door.
- varargout awareness. Variadic varargin and varargout handle flexible signatures: read them fluently, write them rarely.
Reusable Numerical Programs
- Pure functions first. Reusable code is functions, not scripts: no global state, no workspace assumptions.
- Function handles. A handle passes a function to another: integrators and solvers taking your equations.
- Paths and organisation. Code organises on the path: folders and packages, dependencies explicit.
Before and after this level
- Before: Level 2: Matrices & Arrays: Matrix Operations, Indexing, Vectorised Computation.
- Next: Level 4: Data: Tables, Import and Export, Cleaning Experimental Data.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does MATLAB Level 3: Functions cover?
Functions, Inputs and Outputs, Reusable Numerical Programs: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 2: Matrices & Arrays, which covers Matrix Operations, Indexing, Vectorised Computation.