A serial-class, fully programmatic calculator built with native MATLAB UI components. Each functional area is encapsulated in its own class (see table below), enabling you to extend or replace individual modules without touching the rest of the system.
| Core Class | Responsibility |
|---|---|
CalculatorApp |
Entry point — creates the main uifigure, lays out the UI, and wires modules together. |
CalculationDisplay |
Unified scrollable output panel and editable input field with command history. |
NumberPad, AlphaPad |
Provide numeric (0–9, ., -) and hexadecimal (A–F) input buttons. |
ArithmeticOperators |
+ − × ÷ buttons with safe callbacks and symbol normalization. |
TrigonometricFunctions |
Drop-down panel with sin, cos, tan plus inverse/hyperbolic toggles. |
ExponentialLogarithm |
Drop-down panel with exp, ln, log, log10, auto-inserts (. |
RelationalSymbols |
Inserts comparison operators: < > ≤ ≥. |
CommonDelimiters |
Inserts brackets, braces, colons, and commas. |
ActionButtons |
Handles del / clear / enter / menu, validates before eval. |
Why modular?
- Swap out individual modules (pads, rails, display)
- Reuse the engine in a larger app
- Unit-test each component in isolation
- Scientific functions — trigonometry, exponentials, logarithms, π, e, hex input
- Robust expression validation — catches unbalanced delimiters, malformed numbers, invalid operator sequences
- Command history with scrollable display — up to 100 previous results; newest entry is automatically highlighted
- Completely code-based UI — no
.mlappor App Designer files; all layout and styling is done programmatically for version control friendliness
-
Create a new blank MATLAB project (or use an existing one).
-
Copy all
.mfiles from this repository into the same project folder. -
Run the app using either of the following:
-
Open
CalculatorApp.mand press Run in the MATLAB Editor, or -
In the Command Window, type:
myCalculator = CalculatorApp();
-
-
Currently does not support:
- Unit conversions
- Number system conversions
- Graphing or plotting
-
Layout is built with grid containers (
uigridlayout), but does not yet include:- Responsive reflow logic
- Drag/drop component positioning
-
Many additional quality-of-life features are planned but not yet implemented