MATLAB Runtime Server    

Organizing Files and Managing Startup Tasks (GUI)

This section discusses the locations of the files you write for the runtime application. It also discusses the special startup and path definition functions that the Runtime Server invokes when it first runs. These utility functions, matlabrt and pathdefrt, are variations of the functions matlabrc and pathdef that commercial MATLAB invokes upon startup. The table below compares the startup sequences of the two versions of MATLAB; the file shown to the left of an arrow (->) launches the file shown to the right.

MATLAB Variant
Startup Sequence
Commercial
matlab -> matlabrc.m -> pathdef.m
Runtime Server
matlab -> matlabrt.p -> pathdefrt.p

Where to Place Your Files

When you package and ship the application, your files must reside in some directory underneath the MATLAB toolbox directory. This restriction has two important consequences, however:

Creating the Startup Function

The utility function matlabrt, essential for a MATLAB Runtime Server application, is a variation of the matlabrc function that commercial MATLAB uses. To create a matlabrt function for your application, you can modify the template toolbox\runtime\matlabrt_template.m, and place the modified file in toolbox\local. This section describes the properties that your matlabrt function should have.

Properties of the matlabrt Function.   The matlabrt function must:

You can also choose to have matlabrt perform these optional tasks:

Creating the Path Definition Function

The utility function pathdefrt, essential for a MATLAB Runtime Server application, is a variation of the pathdef function that commercial MATLAB uses. This section describes the variations involved and gives information on how you should design pathdefrt.

Properties of the pathdefrt Function.   The pathdefrt function should reside in the toolbox\local directory. It stores the path information and is called from matlabrt when the Runtime Server starts up.

All files that your application uses need to be on the Runtime Server path so that the Runtime Server can find them. This path should include only directories under the toolbox directory. For example, perhaps your own files will reside in toolbox\myapp in the end user's installation and perhaps your files depend on MATLAB functions from toolbox\matlab\general, toolbox\matlab\ops, etc.

The path should also include toolbox\local. Furthermore, if an application uses files from private or class directories (which depfun and depdir will indicate), then these directories should not be added to the path. However, their parent directories should be included on the path. For example, if depdir lists

then the path should include the toolbox\matlab\funfun directory.

Private and class directories are described in the "Programming and Data Types" part of the MATLAB documentation. To find out whether your application uses private or class directories, apply depfun or depdir to the top-level application file and check the results for directories that either are named private or have the @ symbol at the beginning of their names.

Creating the pathdefrt.m Function.   You can adapt the template pathdefrt_template.m provided in the toolbox\runtime directory. To modify it for your application:

  1. Copy pathdefrt_template.m into toolbox\local and rename it pathdefrt.m.
  2. Use the depdir function to find out which directories contain necessary application files. If matlabrt.m is the top-level M-file for your application, then use the command below.
  1. list = depdir('matlabrt');

  1. Omit private and class directories from list.
  2. Paste the contents of list into the pathdefrt.m file that you are building, and edit the lines as necessary to adjust formatting. Path elements should have the form
  1. '$toolbox/matlab/general:'

    and not something like 'C:\Apps\matlab\toolbox\matlab\general'

  1. If your own application files are not currently in a subdirectory of toolbox, then add entries to reflect your ultimate shipping structure. See Where to Place Your Files for more information about where to place your application files.

Other Path Specification Considerations

The Runtime Server generates warnings if it cannot locate all of the directories that are specified on the runtime path. For example, if you specify the specfun directory on the runtime path but do not ship it, then the Runtime Server generates the following warning at startup.

However, on PC platforms, this warning message is not actually visible to your end user because the command window is minimized. On UNIX platforms, if the warning level is not set to off, then the message is displayed in the terminal window.


  Developing a MATLAB Runtime GUI Application Compiling the Application (GUI)