[VCLab-Main] [Software] [MATLAB Plugin]


MATLAB Plugin

The MATLAB Plugin performs communications with MATLAB. It provides mechanisms to do computations in the MATLAB Workspace, to emulate the MATLAB command window output and to put and get data to and from the Workspace.

Embedding ---- Visibility ---- Keys and Parameters
Methods ---- Examples

MATLAB operation

Loading a page with an embedded MATLAB Plugin will start MATLAB in the background on the first load. Depending on the plugin parameters MATLAB will execute statements, which will come with the plugin load. A Java class with a set of methods for MATLAB communication and MATLAB execution on the page are available.

Requirements

The Plugin consists of the dynamic link library NPVCLab.dll and the Java class VCLabPlugin.class, which both reside in the browser plugin directory. The software is installed with the VCLab installer, as shown in the installation guide.

Plugin Embedding at Glance

The plugin can be embedded using different parameters, which influence the startup and visual layout. If the MATLAB command output should be visualized, the embedding by

<EMBED SRC="file.m" WIDTH=400 HEIGHT=350 NAME="name">

may be used. The plugin will load the M-file file.m specified by the SRC key and MATLAB will execute it. The output will be printed in the plugin window, for which the size by HEIGHT and WIDTH is given.

It is also possible, not to specify an M-file but to specify the MIME-type of the plugin. This is performed by the TYPE key

<EMBED TYPE="application/x-matlab" WIDTH=400 HEIGHT=350 NAME="name">

This enables the browser to load this plugin. There is no way at least so far to specify a plugin by its name.

Visibility

In standard plugin embedding the keyword HIDDEN determines the visibility of the plugin window. Due to internal causes, this key is not allowed with this plugin. Instead of this key, the user key DISPLAY must be used. If the parameter is set to "false" the plugin's window is inactive, but the plugin is still running in the background.

<EMBED SRC="file.m" DISPLAY="false" WIDTH=5 HEIGHT=5 NAME="name">

This mechanism enables to keep the contact with the MATLAB engine without showing output. The WIDTH and HEIGHT parameter can be set to a small value. This makes it easy to hide the output of MATLAB from the user.

Optional Keys and Parameters

Parameter Type Syntax
Source
SRC = "URL"
If this parameter is specified, a file will be loaded from the URL as given by the source key.

M-file:
If the file specified in the URL has the extension .m, this file will be executed in the MATLAB workspace. If the file comes from a server, it will be copied before execution to the MATLAB working directory (default: browser cache). If this file is on the browser client, the MATLAB working directory will be set to the file directory before execution.

MM-file:
If the file specified in the URL has the extension .mm, this file is a MATLAB archive. The files in this archive will be extracted to the MATLAB working directory (default: browser cache). If this archive contains the file startup.m or astart.m, this will be executed in the MATLAB workspace.
MM-files may contain any type of files needed for MATLAB execution. The archive format is the standard uncompressed ZIP-format.
Type
TYPE = "application/x-matlab"
The plugin will be specified by its MIME-type. This loads only the plugin, but does not start any MATLAB operation.
Name Identification
NAME = "name"
The name is given to identify the plugin for referencing the plugin methods.
Visibility
DISPLAY = "mode"

mode = true (default)
= false
If false specified, the plugin window is inactive. The WIDTH and HEIGHT parameter can be specified as small as possible, but not zero.
Text Color
FGCOLOR = "rrggbb"
The plugin window default foreground text color (default: green) can be modified by the hex value rrggbb
Background Color
BGCOLOR = "rrggbb"
The plugin window default background color (default: white) can be modified by the hex value rrggbb
Startup Command
STARTUP = "mode"

mode = false (default)
= true
If true specified, an matlab command sequence will be executed on startup. This sequence will be specified by the installer.

Plugin Methods

The plugin provides public Java methods that can be called from Java applets or JavaScript. This allows to implement dynamical actions and computations in MATLAB. The plugin contains an internal matrix storage for buffered communication between MATLAB and the Java methods. This storage can be accessed by someJava methods as shown below.

Operation Syntax
M-file Execution void mEvalMFile(URL MFileURL)
This method loads an M- or MM-file over the web and executes it in the MATLAB workspace. For the MATLAB working directory see the source key syntax in the EMBED tag.

void mEvalMFile(String MFilePath)
This method executes an M- or MM-file in the MATLAB workspace given by the MFilePath. The MFilePath specifies a file path on the client computer system. For the MATLAB working directory see the source key syntax in the EMBED tag.
Command Execution void mEvalString(String evalString)
The string specified by evalString will be executed in the MATLAB workspace. This is the remote version of the MATLAB eval command.
Boolean Expression Evaluation boolean mBoolEvalString(String evalString)
The function will return the boolean value of the scalar boolean expression specified in evalString.
Remove Variable in Workspace void mClear(String NameString)
Removes the MATLAB workspace variable given by NameString.
Clear Workspace void mClearAll()
Removes all from the MATLAB workspace.
Get Matrix from Workspace String mGetArray(String MatrixName)
This function gets the matrix specified by MatrixName from the workspace and stores it in the plugin matrix storage. The function returns this matrix described by a string in the LaTeX array notation as specified by the HotEqn applet.
Get a Scalar Variable from Workspace double mGetArray(String MatrixName, String m, String n)
This function gets the matrix specified by MatrixName from the workspace and stores it in the plugin matrix storage. The function returns the (m,n)-element of the matrix. Low index is 1.
Get a Scalar String Variable from Workspace String mGetString(String MatrixName, String m )
This function gets the string matrix specified by MatrixName from the workspace and stores it converted into equivalent double values in the plugin matrix storage. The function returns the m-th element of the string matrix as a string. Low index is 1.
Put Matrix to Workspace boolean mPutArray(String MatrixName)
Puts the matrix stored in the plugin matrix storage to the workspace and assigns it the variable name given by MatrixName. If this operation is successful the function returns true, otherwise false.
Matrix to LaTeX Conversion String mMatrix2LaTeX()
The function returns the matrix stored in the plugin matrix storage described by a string in the LaTeX array notation as specified by the HotEqn applet.
LaTeX to Matrix Conversion void mLaTeX2Matrix(String LaTeXString)
The array given in LaTeX notation in LaTeXString is converted to a matrix and stored in the plugin matrix storage.
Get Matrix Number of Rows int mGetM()
Function returns the number of rows of the matrix stored in the plugin matrix storage.
Get Matrix Number of Columns int mGetN()
Function returns the number of columns of the matrix stored in the plugin matrix storage.
Set User Level void mSetUserLevel(String UserLevel)
The user level value will be set internal in the plugin and stored in the MATLAB workspace variable UserLevel.
Get User Level int mGetUserLevel()
The user level value will be returned from the plugin storage.
Get MATLAB Version double mGetMatlabVersion()
Return the decimal number of the current MATLAB version.
Get Plugin Version double mGetNPVCLabVersion()
Returns the decimal number of the current Plugin version.
Get Java Version double mGetJavaVersion()
Returns the decimal number of the current Plugin Java methods version.

Examples (needs the VCLab Plugins installed, see Installation Guide)

Basic example with embedding, M-file and string execution
MM-file execution example
Miscellaneous functions example

[VCLab-Main] [Software] [MATLAB Plugin]


©CS 1996, 1997, 1998, 2001