Lesson 25-MATLAB App Designer Graphical Interface Development

Introduction: The Democratization of Technical Computing Through GUIs

The power of a computational tool is ultimately measured not by the sophistication of its algorithms or the elegance of its programming language, but by the breadth of its user base—the range of people who can effectively apply that tool to solve real problems. MATLAB has long been a cornerstone of technical computing in academia, engineering, and scientific research. Its matrix-centric programming model, extensive toolboxes, and interactive environment make it an extraordinarily productive platform for engineers and scientists who are also competent programmers. However, the vast majority of domain experts—the practicing control engineer tuning a PID loop on a physical plant, the experimental physicist analyzing particle collision data, the financial analyst constructing risk models, the biomedical researcher processing microscopy image sequences—are not expert programmers. They possess deep domain knowledge and a clear sense of the computations they need to perform, but they lack the time (or sometimes the inclination) to master MATLAB’s programming language, debugging tools, and ecosystem of functions and toolboxes.

This gap between computational capability and user accessibility is precisely what Graphical User Interfaces (GUIs) bridge. A well-designed GUI transforms a MATLAB script or function—which requires the user to understand syntax, data formats, and programming concepts—into an interactive application that presents a curated set of controls (buttons, sliders, dropdown menus, file dialogs) and visual outputs (plots, tables, status indicators). The domain expert interacts with the application through familiar GUI metaphors: clicking a button to load data, adjusting a slider to vary a parameter and immediately seeing the updated plot, selecting options from dropdown menus to configure analysis parameters. The underlying MATLAB code—the data processing pipelines, the visualization routines, the optimization algorithms—remains entirely hidden, encapsulated behind the GUI. This encapsulation is not merely a convenience; it is a fundamental enabler of computational democratization. By building GUIs for your MATLAB algorithms, you transform them from programmer-only tools into instruments that domain experts across your organization can use productively.

MATLAB has historically provided two primary frameworks for building GUIs: GUIDE (GUI Development Environment), introduced in the late 1990s, and App Designer, introduced in MATLAB R2016a as the modern successor to GUIDE. If you have ever opened GUIDE (by typing guide at the MATLAB command prompt), you have seen its aging interface: a figure-based layout editor that generates MATLAB code (.m files) with a complex, callback-intensive structure that many users found difficult to debug and extend. GUIDE has been formally deprecated by MathWorks; it will be removed in a future release. No new development should target GUIDE.

App Designer, by contrast, represents a complete reimagining of GUI development in MATLAB. It provides a modern, richly interactive design environment (the “Design View”) coupled with a sophisticated code editor (the “Code View”) that supports component callbacks, property management, and sophisticated app life-cycle handling. Apps created in App Designer are saved as .mlapp files (a proprietary binary format that encapsulates both the design layout and the callback code). App Designer generates applications that run in the MATLAB web-based figure system (uifigure), which provides substantially richer rendering fidelity, smoother interactivity, and better cross-platform consistency than the legacy figure system that GUIDE uses.

But the significance of App Designer extends far beyond cosmetic modernization. Under the hood, App Designer applications are rendered using HTML5, CSS, and JavaScript—the same web technologies that power modern web applications. When you run an App Designer application, MATLAB does not simply draw pixels onto a figure window (as the legacy figure system does). Instead, it launches a lightweight web server (hosted within the MATLAB process), serves the app’s user interface as HTML/CSS/JS assets to an embedded web renderer (based on Chromium), and communicates user interactions (button clicks, slider adjustments) back to the MATLAB runtime via asynchronous message passing (WebSocket or similar). This architecture—MATLAB as the computational backend, web technologies as the rendering and interaction frontend—is why App Designer applications look and feel like modern web applications: smooth animations, responsive controls, high-DPI scaling that respects operating system display settings, and support for rich UI components (trees, tables with sorting/filtering, tab groups, grid layouts that reflow on window resize) that the legacy figure system could not render.

This architectural decision—embedding a web renderer within MATLAB—has profound implications for the types of applications you can build, the deployment options available to you, and the performance characteristics you can expect. It also explains why App Designer is the future of GUI development in MATLAB and why every MATLAB user who builds or maintains interactive applications should migrate to it.

This article provides a comprehensive, deep exploration of App Designer. We will examine not just the mechanics of dragging components onto a canvas and writing callbacks (though we will cover those exhaustively), but also the conceptual foundations that make App Designer applications work: the event-drivien programming model, the object-oriented architecture of App Designer apps (they are MATLAB classes, not scripts or functions), the life-cycle management of app instances (startup, running, shutdown), the data-sharing mechanisms that enable different callbacks to communicate (properties with different access levels), and the packaging and deployment pipeline that transforms your .mlapp into a standalone executable that runs on machines without MATLAB installed.

By the end of this article, you will possess not merely the ability to build simple GUIs in App Designer, but the deeper architectural understanding to design sophisticated, production-quality applications: multi-window apps with modal dialogs and data passing between windows, apps that handle asynchronous computation (keeping the UI responsive while a long computation runs in the background), apps that package complex visualization and analysis pipelines into intuitive interfaces that domain experts can master in minutes, and apps that deploy robustly to end-users through MATLAB Compiler, web apps (MATLAB Web App Server), or even as full web applications (using MATLAB Production Server). This knowledge will enable you to bridge the gap between computational capability and user accessibility—to transform your MATLAB algorithms from programmer-only tools into production applications that deliver value across your organization.

GUIDE vs. App Designer: A Detailed Comparison and Migration Path

To understand why App Designer represents the future of GUI development in MATLAB, you must first understand the historical context: GUIDE, its limitations, and the architectural decisions that necessitated a clean-slate redesign. This historical perspective is not mere nostalgia; it informs the design decisions in App Designer and helps you avoid misapplying patterns that were appropriate for GUIDE but are suboptimal or impossible in App Designer.

GUIDE: The Legacy Framework and Its Limitations

GUIDE (GUI Development Environment) was introduced in MATLAB 5.0 (1996) as a graphical interface for building GUIs. It was, for its time, a remarkable productivity booster: it provided a drag-and-drop layout editor (the “GUIDE figure”), automatically generated a .m file with boilerplate callback wiring, and exposed a set of functions (guidata, guihandles, setappdata, getappdata) for sharing data between callbacks.

However, GUIDE’s architecture imposed fundamental limitations that became increasingly problematic as users built more sophisticated applications:

Limitation 1: Legacy Figure System: GUIDE GUIs are built on MATLAB’s legacy figure system (figure, uicontrol, uimenu, etc.). This rendering pipeline, originally designed in the 1980s for monochrome displays and single-threaded event loops, has fundamental limitations: poor support for high-DPI displays (on Windows, figures may appear blurry or incorrectly scaled), inconsistent rendering across operating systems (a GUI that looks correct on Windows may have misaligned components on macOS or Linux), limited UI component selection (no tree controls, no modern table controls with sorting/filtering, no tab groups or grid layouts), and no support for touch interactions or modern accessibility standards.

Limitation 2: Complex Data Sharing via guidata and guihandles: In GUIDE, sharing data between callbacks (e.g., a “Load Data” button callback stores data that a “Plot Data” button callback later uses) requires using guidata (store/retrieve the GUI’s application data) or setappdata/getappdata (attach arbitrary data to graphics objects). These mechanisms are error-prone (you must remember field names as strings, leading to silent bugs from typos), provide no encapsulation (any callback can access any app data), and make it difficult to build large applications with many callbacks (the “app data struct” becomes a monolithic, undocumented container).

Limitation 3: No Object-Oriented Architecture: A GUIDE GUI is not a MATLAB object; it is a collection of callbacks (subfunctions in the generated .m file) that communicate through the figure’s application data. This non-object-oriented design makes it impossible to create multiple independent instances of the same GUI (e.g., two figure windows showing different datasets), difficult to componentize and reuse GUI elements across projects, and antithetical to modern software engineering practices (encapsulation, inheritance, polymorphism).

Limitation 4: Limited Layout Management: GUIDE uses absolute positioning (you drag components to specific pixel coordinates). When the user resizes the window, components do not reflow; they remain at fixed positions, leaving awkward empty spaces or causing overlapping controls. While you can use ResizeFcn callbacks to manually reposition components on window resize, this is tedious, error-prone, and produces brittle layouts that break when you add or remove components.

Limitation 5: No Support for Web or Mobile Deployment: GUIDE GUIs run only within the MATLAB desktop or as standalone applications (via MATLAB Compiler). They cannot be deployed as web applications (accessible through a browser) or mobile applications. In an era where users expect browser-based access to computational tools, this limitation is increasingly prohibitive.

Because of these limitations (and others), MathWorks deprecated GUIDE and introduced App Designer as its modern replacement.

App Designer: The Modern Framework and Its Advantages

App Designer, introduced in MATLAB R2016a and substantially enhanced in every subsequent release, addresses every limitation of GUIDE through a ground-up redesign of the GUI development framework. Understanding App Designer’s architecture and advantages is essential for making effective use of it.

Advantage 1: Web-Based Rendering (uifigure): App Designer apps run on MATLAB’s modern web-based figure system (uifigure, uibutton, uislider, etc.). This system renders UI components using HTML5/CSS/JavaScript within an embedded Chromium renderer. The advantages are substantial: high-DPI display support (UI components scale crisply on Retina or 4K displays), cross-platform rendering consistency (the web renderer ensures that apps look identical on Windows, macOS, and Linux), rich UI component library (trees, sortable/filterable tables, tab groups, grid layouts, date pickers, spinners, and many more components that GUIDE cannot render), and support for touch interactions (pinch-to-zoom on axes, touch-friendly button sizes).

Advantage 2: Object-Oriented Architecture (Apps as MATLAB Classes): An App Designer app is a MATLAB class (subclass of matlab.apps.AppBase). This object-oriented design has profound implications: you can create multiple independent instances of the same app (each is a separate object with its own state), encapsulate data and methods (properties and methods with access control: public, private, protected), and even create app hierarchies (one app subclassing another, inheriting its components and callbacks). If you have built object-oriented MATLAB applications (using classdef classes), App Designer apps will feel familiar: they are simply a specialized class with UI components as properties and callbacks as methods.

Advantage 3: Properties for Data Sharing (Cleaner Than guidata): In App Designer, you share data between callbacks by defining properties (class-level variables) in the app. A property is a named data container that is accessible to all callbacks (methods) of the app. Properties have access-control attributes: public (accessible from outside the app), private (accessible only within the app), and protected (accessible within the app and its subclasses). This property-based data sharing is substantially cleaner than GUIDE’s guidata approach: properties have meaningful names (autocompleted by the MATLAB editor), their types can be documented (using comments or, in newer MATLAB versions, the arguments validation block), and they provide natural encapsulation (private properties are hidden from external code, reducing the risk of accidental data corruption).

Advantage 4: Grid Layouts and Auto-Reflow (Responsive Design): App Designer provides a sophisticated layout system: you can position components using either absolute coordinates (like GUIDE) or, much more powerfully, using grid layouts (uigridlayout). A grid layout divides the app window into rows and columns; you place UI components into specific grid cells; and when the user resizes the window, the grid reflows (rows and columns can have fixed sizes, weighted sizes, or auto-sizes that adapt to content). This responsive design capability—which is table stakes for modern web and mobile UI development—enables you to build apps that look professional at any window size, from small laptops to large 4K monitors.

Advantage 5: Multi-Window Support and Modal Dialogs: App Designer provides first-class support for multi-window applications. You can create a “main” app and “dialog” apps; launch the dialog as a modal window (blocking interaction with the main window until the dialog is dismissed); and pass data between the main app and the dialog (via properties, constructor arguments, or output functions). Building multi-window apps in GUIDE required manual management of figure handles and application data; in App Designer, it is a natural consequence of the object-oriented architecture (each window is an app object; you pass data between them as you would between any two MATLAB objects).

Advantage 6: Web and Mobile Deployment Paths: Because App Designer apps render via web technologies (HTML/CSS/JS), they are architecturally aligned with web deployment. Using MATLAB Web App Server (separate product), you can deploy App Designer apps as web applications accessible through a browser—no MATLAB installation required on the client side. Using MATLAB Compiler, you can package App Designer apps as standalone executables (.exe on Windows, .app/.sh on macOS/Linux) that run without MATLAB. Using MATLAB Compiler SDK, you can even package app logic as a web API (RESTful) that serves browser-based JavaScript frontends. These deployment paths—impossible or deeply cumbersome with GUIDE—are natural consequences of App Designer’s web-based rendering architecture.

Migration from GUIDE to App Designer: Strategies and Challenges

If you have existing GUIDE GUIs that you need to maintain or upgrade, you face a migration decision: should you invest in porting them to App Designer, or continue maintaining them in GUIDE (acknowledging that GUIDE is deprecated and will eventually be removed)?

Decision Framework: When to Migrate:

  1. Migrate if: The GUI is actively maintained (you are adding features, fixing bugs, or adapting to new requirements); the GUI would benefit from modern UI components (tables with sorting, tree controls, tab groups); the GUI needs to run on high-DPI displays or multiple operating systems; or you need web deployment (Web App Server).
  2. Do NOT migrate if: The GUI is stable (no active development); it uses specialized legacy figure features (custom Java frames, ActiveX controls) that have no App Designer equivalent; or the migration cost (measured in developer hours) exceeds the expected maintenance cost of keeping it in GUIDE.

Migration Strategy 1: Automated Conversion (Limited):

MathWorks provides a limited automated conversion tool (guideToAppDesigner) that attempts to convert GUIDE .fig/.m pairs to App Designer .mlapp files. However, this tool is constrained: it can convert only simple GUIDE GUIs (those using standard uicontrol components and simple callbacks); it cannot convert GUIs that use advanced features (Java frames, custom rendering, complex ResizeFcn logic); and the converted output often requires manual cleanup (property names change, callback signatures change, guidata-based data sharing must be refactored to property-based sharing).

Given these limitations, automated conversion is best viewed as a starting point for simple GUIs, not a complete solution. For complex GUIDE GUIs, manual rewriting in App Designer is typically more efficient than debugging an incomplete automated conversion.

Migration Strategy 2: Manual Rewrite (Recommended):

For non-trivial GUIDE GUIs, the most reliable migration strategy is a manual rewrite in App Designer. This may sound daunting—effectively reimplementing the GUI from scratch—but it is often more efficient than it appears, for several reasons:

  1. App Designer’s richer component library reduces custom code: Many GUIDE customizations (custom listbox rendering, table cell formatting) required writing low-level figure code or Java workarounds. In App Designer, equivalent functionality is often available as a built-in component (sortable tables, tree controls) that requires no custom code.
  2. Property-based data sharing is cleaner: Refactoring guidata/setappdata calls into app properties typically simplifies the code (properties are explicitly named, typed, and encapsulated) and surfaces bugs (misspelled field names that were silent in guidata become explicit errors when you access a nonexistent property).
  3. Grid layouts eliminate manual resize logic: If the GUIDE GUI has a complex ResizeFcn that manually repositions components on window resize, the App Designer equivalent (using uigridlayout) eliminates this code entirely—the grid reflows automatically.

The manual rewrite strategy proceeds in four phases:

Phase 1: Inventory and Prioritization: Document the GUIDE GUI’s functionality (all buttons, all callbacks, all data flows). Identify which features are essential (must be ported), which are nice-to-have (should be ported), and which are obsolete (can be dropped). This inventory prevents you from mindlessly porting legacy design decisions that are no longer relevant.

Phase 2: Implement Core Layout in App Designer: Create a new App Designer project. Recreate the GUI layout using App Designer’s Design View. Use grid layouts (uigridlayout) rather than absolute positioning. Select UI components from App Designer’s component library (which is richer than GUIDE’s). Do not implement callbacks yet; focus on layout fidelity.

Phase 3: Port Callbacks and Data Sharing: For each GUIDE callback, create the equivalent App Designer callback (the mechanism is similar: you select a component, choose a callback type (e.g., ButtonPushed, ValueChanged), and App Designer generates a callback method stub). Refactor guidata/getappdata calls to use app properties. Test each callback independently.

Phase 4: Testing and Polish: Test the migrated app comprehensively (all user flows, all edge cases). Pay particular attention to differences in rendering (App Designer uses web-based rendering; some visual behaviors differ from the legacy figure system). Add responsive layout logic (grid layout reflow) if not already present.

Membership Required

You must be a member to access this content.

View Membership Levels

Already a member? Log in here

Share your love