How mathworks/arithmetic works
Project Type and Purpose
• This is a MATLAB toolbox example (a library of functions, live tasks, apps, and examples).
• Purpose: demonstrate MATLAB toolbox best practices—namespaces, packaging, unit tests, live tasks, apps, and example scripts.
File Structure
• Top-level packaging and project files:
– arithmetic.prj, toolboxPackaging.prj, buildfile.m
• Core toolbox code under “toolbox/”:
– Public functions: toolbox/add.m, toolbox/+describe/add.m
– Namespaces/packages: toolbox/+describe/
– Internal implementation and resources: toolbox/internal/, toolbox/internal/resources/liveTasks.json
– App file: toolbox/apps/arithmetic.mlapp
• Examples and documentation:
– toolbox/examples/usingAdd.mlx, toolbox/gettingStarted.mlx
• Unit tests:
– tests/testAdd.m, tests/testIntToWord.m
• External resources:
– resources/project/Project.xml, UUID .xml files
• Misc: README.md, images/, LICENSE, SECURITY
Extract Architectural Insights from the README
• Emphasis on MATLAB features: argument validation, custom tab completion, live tasks, apps, packaging.
• No external services—entirely contained within MATLAB environment.
Main Components
1. Core Function Library
– Public APIs (add, intToWord) located at toolbox/add.m and toolbox/+describe/add.m
2. Internal Helpers & Resources
– Internal functions (intToWord.m, addLiveTask.m) and liveTasks.json
3. MATLAB App
– arithmetic.mlapp
4. Examples & Documentation
– Live scripts (usingAdd.mlx, gettingStarted.mlx)
5. Test Suite
– Function-based tests in tests/
6. Packaging & Build
– buildfile.m, *.prj project definitions, toolboxPackaging.prj
7. Project Files & Versioning
– resources/project/Project.xml and UUID metadata
Relationships & Interactions
– Tests (verify behavior)
– App (uses API)
– Examples (demonstrate API)
– Live Tasks (integrate into MATLAB Editor via addLiveTask.m)
• Packaging process:
– buildfile.m reads source, resources, project files → produces .mltbx
• Project file (.prj):
– Defines toolbox structure and metadata for MATLAB Projects and build tool.
Architectural Patterns & Principles
• Namespace/package separation (toolbox/+describe)
• Encapsulation of internal code (toolbox/internal)
• Clear separation of concerns: API vs. implementation vs. tests vs. examples
• Declarative metadata (XML files) for project and toolbox packaging
• Single-toolbox, single-workspace model—no microservices or external dependencies
Relevant Technologies & Frameworks
• MATLAB language & environment
• MATLAB Toolbox packaging (.mltbx)
• Live Editor Tasks (JSON‐driven)
• MATLAB Apps (.mlapp)
• MATLAB unit testing framework