MATLAB Runtime Server | ![]() ![]() |
Overview of the Application
This example is a simple GUI-driven application that calculates and displays an amortization schedule. If you have added toolbox\runtime\examples\gui
to the MATLAB path, then you can run the application by typing
at the command line. At first, the GUI looks like this.
To use the application, enter expressions in the GUI fields and press the Calculate button. After you enter values and press Calculate, the GUI looks like this.
The Clear button deletes the numbers that you entered in the four input fields. The Close button exits the application. If the application is running with the Runtime Server or with commercial MATLAB in runtime emulation mode, then the Close button also exits MATLAB.
How the Application Files Interact
If you run the application with the Runtime Server, then the Runtime Server first executes matlabrt
, which in turn invokes pathdefrt
. The function matlabrt
also executes amortsched
, which sets up the GUI and the buttons' callback functions. Below is an excerpt from amortsched.m
.
h0 = figure('Color',[0.8 0.8 0.8], ... 'CloseRequestFcn','amortsched_cb(''close_amortsched'')', ... 'MenuBar','none', ... 'Name','Amort Sched 1.0', ... 'NumberTitle','off', ... 'PaperPosition',[18 180 576 432], ... 'PaperUnits','points', ... 'Units','characters', ... 'Position',[68.6 7.3077 136 21.7692], ... 'Resize','off', ... 'Tag','Fig1', ... 'ToolBar','none'); h1 = uicontrol('Parent',h0, ... etc...
Pressing the buttons invokes amortsched_cb
with an argument indicating which button was pressed. The function amortsched_cb
uses a switch
structure to perform the actions associated with each GUI button. The lines below show the structure of amortsched_cb.m
.
switch action case 'clear_values' % Insert code here that clears the GUI fields. case 'calculate_values' % Insert code here that calculates and displays % the amortization schedule. case 'close_amortsched' % Insert code here that exits the application. end
When necessary, amortsched_cb
invokes other functions to compute or display results.
The figure below illustrates schematically which functions call each other in this application.
![]() | Installing the Example Files | Adapting the Design for Runtime Execution | ![]() |