matlab/matlab-agentic-toolkit / skills-catalog/matlab-app-building/matlab-build-app
matlab-build-app
UnverifiedBuild MATLAB apps from requirements to working code. Asks discovery questions (or skips them when the path is known), recommends UIFigure or UIHTML architecture, identifies layout archetype (Dashboard, Explorer, Tabbed, Wizard, Canvas), produces an implementation plan, and executes the build. For UIFigure apps, optionally serializes as App Designer (.mlapp or plain-text .m + .xml). Use when a user wants to build a MATLAB app, create a GUI, make an interactive tool, build a uifigure app, build a uihtml app, build an App Designer app, build a .mlapp app, build a plain-text App Designer app, or asks which approach to use. Also use when user describes spatial layout needs: dashboard, control panel, sidebar, tabs, wizard, stepper, canvas, workspace.
references/uifigure/mvvm-view-binding.md
View on GitHub# View Binding Pattern
Complete MainView class demonstrating how to bind a MATLAB uifigure View to a ViewModel using `addlistener` on `SetObservable` properties.
## MainView Class
```matlab
classdef MainView < handle
properties (Access = private)
Figure
ViewModel
Listeners
% UI components that need updating
ResultLabel
StatusLabel
ProcessButton
MethodDropdown
end
methods
function obj = MainView(viewModel)
arguments
viewModel AppName.ViewModels.MainViewModel
end
obj.ViewModel = viewModel;
obj.Listeners = listener.empty;
obj.createUI();
obj.bindToViewModel();
obj.syncFromViewModel(); % Initial state
end
function delete(obj)
delete(obj.Listeners);
if isvalid(obj.Figure)
delete(obj.Figure);
end
end
function show(obj)
obj.Figure.Visible = 'on';
end
end
methods (Access = private)
function createUI(obj)
obj.Figure = uifigure('Name', 'MVVM App', ...
'Position', [100 100 500 300], ...
'Visible', 'off', ...
'CloseRequestFcn', @(~,~) delete(obj));
gl = uigridlayout(obj.Figure, [4 2]);
gl.RowHeight = {'fit', 'fit', 'fit', '1x'};
gl.ColumnWidth = {120, '1x'};
gl.Padding = [10 10 10 10];
% Row 1: Method selection
uilabel(gl, 'Text', 'Method:');
obj.MethodDropdown = uidropdown(gl, ...
'Items', {'linear', 'quadratic', 'cubic'});
% Row 2: Buttons
uibutton(gl, 'Text', 'Load File...', ...
'ButtonPushedFcn', @(~,~) obj.onLoadClicked());
obj.ProcessButton = uibutton(gl, 'Text', 'Process', ...
'ButtonPushedFcn', @(~,~) obj.onProcessClicked());
% Row 3: Result
uilabel(gl, 'Text', 'Result:');
obj.ResultLabel = uilabel(gl, 'Text', '');
% Row 4: Status bar spanning both columns
obj.StatusLabel = uilabel(gl, 'Text', 'Ready');
obj.StatusLabel.Layout.Column = [1 2];
obj.StatusLabel.HorizontalAlignment = 'center';
end
function bindToViewModel(obj)
vm = obj.ViewModel;
obj.Listeners(end+1) = addlistener(vm, 'DisplayText', 'PostSet', ...
@(~,~) set(obj.ResultLabel, 'Text', vm.DisplayText));
obj.Listeners(end+1) = addlistener(vm, 'StatusMessage', 'PostSet', ...
@(~,~) set(obj.StatusLabel, 'Text', vm.StatusMessage));
obj.Listeners(end+1) = addlistener(vm, 'IsProcessing', 'PostSet', ...
@(~,~) obj.onIsProcessingChanged());
obj.Listeners(end+1) = addlistener(vm, 'CanProcess', 'PostSet', ...
@(~,~) obj.onCanProcessChanged());
end
function syncFromViewModel(obj)
obj.ResultLabel.Text = obj.ViewModel.DisplayText;
obj.StatusLabel.Text = obj.ViewModel.StatusMessage;
obj.onIsProcessingChanged();
obj.onCanProcessChanged();
end
%% ViewModel -> View (property change handlers)
function onIsProcessingChanged(obj)
busy = obj.ViewModel.IsProcessing;
obj.ProcessButton.Enable = ~busy;
obj.MethodDropdown.Enable = ~busy;
end
function onCanProcessChanged(obj)
obj.ProcessButton.Enable = obj.ViewModel.CanProcess ...
&& ~obj.ViewModel.IsProcessing;
end
%% View -> ViewModel (user action handlers)
function onProcessClicked(obj)
obj.ViewModel.processCommand(obj.MethodDropdown.Value);
end
function onLoadClicked(obj)
[file, path] = uigetfile('*.csv;*.txt;*.mat', 'Select data file');
if file ~= 0
obj.ViewModel.loadFileCommand(fullfile(path, file));
end
end
end
end
```
## View Design Guidelines
- All UI creation and `uigridlayout` patterns come from `guide.md`
- Use `addlistener` to bind ViewModel observables to UI updates
- Store listeners in an array and `delete` them in the destructor
- Wire user events (ButtonPushedFcn, ValueChangedFcn) to ViewModel commands
- The View never talks to the Model directly
- For simple bindings, use inline `set()`: `@(~,~) set(label, 'Text', vm.Prop)`
- For complex bindings (enable/disable logic), use a private method
## Binding Patterns
### Simple binding (one property → one component)
```matlab
addlistener(vm, 'StatusMessage', 'PostSet', ...
@(~,~) set(obj.StatusLabel, 'Text', vm.StatusMessage));
```
### Complex binding (multiple properties → component state)
```matlab
addlistener(vm, 'IsProcessing', 'PostSet', ...
@(~,~) obj.updateButtonState());
function updateButtonState(obj)
canAct = obj.ViewModel.CanProcess && ~obj.ViewModel.IsProcessing;
obj.ProcessButton.Enable = canAct;
if obj.ViewModel.IsProcessing
obj.ProcessButton.Text = "Processing...";
else
obj.ProcessButton.Text = "Process";
end
end
```
### Initial sync
Always call a `syncFromViewModel()` method after binding to set initial UI state from current ViewModel values — listeners only fire on *change*, not on initial value.
----
Copyright 2026 The MathWorks, Inc.
----
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |