Multiway Analysis of Multivariate Longitudinal Data
(Meerweganalyse van Multivariate Longitudinale Data)

Design and implementation of a generic user interface to MATLAB statistical analysis routines

Henk-Jan Slotboom hslotboo at fsw.leidenuniv.nl

v0.1.2, Nov 2 1999

This document is a draft of the generic user interface currently under development. The interface will be running stand-alone and uses both MATLAB and C/C++ code. A description of the current interface is given, as well as guidelines for writing MATLAB routines to be included in the interface.

1. Introduction

2. Requirements

See also Windows System Requirements for up-to-date information.


Provides the basic environment for MATLAB development. Required.

MATLAB Compiler 2.0.1

Translates MATLAB code into C or C++ code. Required.

MATLAB C/C++ Math Library 2.0.1

Contains implementation hooks to most mathematical functions found in translated MATLAB code. Required.

MATLAB C/C++ Graphics Library 1.0

Contains hooks to most graphics functions (i.e. plot, uimenu etc.) used in translated MATLAB code. Optional.

ANSI C/C++ Compiler

For compiling and linking the translated MATLAB code, a supported compiler has to be installed on the system. Currently only the Borland, Microsoft and Watcom C/C++ compilers are supported.

3. The Interface

3.1 MFC and the Document/View architecture

The interface is written in Microsoft Visual C++ using Microsoft Foundation Classes (MFC). These classes provide a general framework for building Windows applications. An often used feature of MFC is the the Document/View architecture: the Document contains the `real' data currently in memory, while the View displays and updates the Document's data. More than one view may be defined for a single document.

3.2 The Document types

The MATLAB document

The MATLAB document contains a set of MATLAB arrays. A set of arrays is read from a binary MATLAB (*.mat) file. These files can be created or consulted in MATLAB by using the read and save commands. When saving a MATLAB document, the set is written to a MATLAB file. Cell arrays and structures in MATLAB files are disgarded by the interface.

The ASCII document

Regular ASCII text is contained in the ASCII document. Files using the extensions (*.asc, *.dat, *.txt) usually belong the this class.

3.3 The View types

The MATLAB view

The main view on a MATLAB document is the TreeView. It is used to select an array from the set. The selected array is then displayed in a GridView on the right of the TreeView. Cells in the spreadsheet-like GridView can be edited, or can be copied and moved to another location.

3.4 The Analysis routines

The translated MATLAB routines are accessible through the Run menu. When the user selects one of the routines, the interface transfers the current set of arrays to the routine and executes it. When the routine exits, a new document is created and filled with the set of arrays returned by the routine.

3.5 The Parameters

Each MATLAB routine has to input the user for possible input parameters. When the routine has completed its work, it returns the input parameters to the interface. The next time the interface calls the routine, the saved parameters are transferred along with the set of arrays. It then serves as a set of default values for the user input of parameters.

3.6 The Plotting routines

Plotting data is implemented in MATLAB code using the functions available in the MATLAB C/C++ Graphics Library. The plotting routines are hooked to entries in the interface's Plot menu. OK?

4. Building the project

4.1 With Microsoft Visual C++ Studio

  1. Translate all MATLAB routines to be included in the interface. Enter the command mcc -t -L cpp routine.m at the MATLAB prompt to create an equivalent C++ routine. If a routine makes use of other M-files, they will be translated as well.
  2. Start Microsoft Visual C++ Studio and open the project project. Add all .cpp and .hpp files the MATLAB compiler created to the project. Add an entry for each new routine to the Run menu.

5. MATLAB code limitations

5.1 Script M-files

M-Files not starting with the keyword function are Scripts M-files. These scripts use and modify the variables available in the workspace. As the workspace in unavailable in stand-alone applications, the Compiler cannot compile Script M-files.

Work-around: Use Function M-files. A function does not use the workspace. The function's caller passes variables as arguments to the function, which in turn returns some variables to the caller. All variables used in the function only are lost. For example, the following function changes A and B to respectively eig(X) and eig(Y), while the value of Y is lost.

function [A,B] = svd(X)
  Y = rand(4);
  A = eig(X);
  B = eig(Y);

5.2 Classes and Objects

Classes and Objects, which are instances of Classes, cannot be translated by the MATLAB compiler.

Work-around: None.

5.3 eval and input

These functions create and use internal variables that only the MATLAB interpreter can handle.

Work-around: None.