Vectorisation
- Vectorise the loop. The first optimisation is vectorisation: the loop restated as array operations.
- Preallocation. Growing arrays inside loops copies every pass: preallocate with zeros and fill.
- Built-ins win. Built-in functions run compiled C underneath: your loop competes and loses.
Profiling
- The profiler. The profiler attributes time per line: measured hotspots over folklore.
- timeit. timeit benchmarks functions honestly: warmed, repeated, median reported.
- Memory in the profiler. The profiler tracks memory too: copies and growth caught beside time.
Memory-Efficient MATLAB
- Copy-on-write. MATLAB copies arrays lazily: mutation inside functions triggers the real copy.
- In-place patterns. Same-variable operations enable in-place updates: x = x + 1 without a second array.
- Right-sized types. single and integer types halve memory where precision allows: chosen, documented.
Before and after this level
- Before: Level 9: Object-Oriented MATLAB: Classes, Properties and Methods, Reusable Engineering Components.
- Next: Level 11: Testing & Reproducibility: Unit Tests, Reproducible Scripts, Engineering-Quality MATLAB.
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 10: Performance cover?
Vectorisation, Profiling, Memory-Efficient MATLAB: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 9: Object-Oriented MATLAB, which covers Classes, Properties and Methods, Reusable Engineering Components.