MATLAB Release Notes    

External Interfaces/API Features

MATLAB Interface to Java

The new Java capability enables you to conveniently bring Java classes into the MATLAB environment, to construct objects from those classes, to call methods on the Java objects, and to save Java objects for later reloading -- all accomplished with MATLAB functions and commands. You can also develop your own Java class definitions and make them available for use in MATLAB.

The MATLAB Java interface is intended for all MATLAB users who want to take advantage of the special capabilities of the Java programming language. The interface enables you to

You construct Java objects in MATLAB by calling the Java class constructor, which has the same name as the class. For example, the following constructor creates a Frame object with the title 'Frame A'. Any other properties are set to their default values.

You call methods on this object using either Java syntax

Or MATLAB syntax.

You can create n-dimensional arrays of Java objects and call methods on the arrays. You reference and assign to elements of those arrays using MATLAB matrix syntax. You can pass either MATLAB data or Java objects to the methods of Java classes. MATLAB performs data type conversion on this data where necessary.

See Calling Java from MATLAB under "External Interfaces/API" in the online help, for full documentation of this feature.

New Functions for the Interface to Java

MATLAB 6.0 provides the following new functions to support the interface to Java.

Function
Purpose
import
Add to the current Java packages import list
isjava
Test whether an object is a Java object
javaArray
Construct a Java array
javaMethod
Invoke a Java method (used only in special cases)
javaObject
Construct a Java object (used only in special cases)
methodsview
Display information on all methods implemented by a Java or MATLAB class

Existing Functions with Java Functionality Added

The following MATLAB functions now operate on Java objects, classes, and methods.

Function
Purpose
cell
Convert a Java object array into a MATLAB cell array
char
Convert a java.lang.String object or array to a char array or cell array of char arrays
class
Return a Java class name
clear import
Remove the Java packages import list
depfun
Return Java class names that the file and its subordinates use
disp
Display a Java object
double
Convert a Java object or array to a double array
exist
Determine if a Java class exists
fieldnames
Return the field names of a Java object
inmem
Return the names of loaded Java classes
isa
Identify an object as a Java class
isequal
Compare Java objects for equality
methods
Return all methods of a Java class
struct
Convert a Java object or array to a MATLAB structure or structure array
which
Return the package, class, and method name for a Java class method

Restriction on Unloading Java Classes

If you load a Java class into MATLAB and, sometime later, modify and recompile the class, you must exit and restart MATLAB in order to use the updated class definition. This restriction exists because the Java VM does not provide a way to unload a Java class once it has been loaded. Exiting and restarting MATLAB terminates and restarts the Java VM, which then allows you to load the updated class.

Similarly, the import function will not import an updated class definition. You must first exit and restart MATLAB.

Java Version

The Java version used by MATLAB differs by platform and for Release 12 is as shown in the following table.

Platform
Java Version
Compaq Alpha
1.1.8-5
IBM
1.2.2
Linux
1.1.8
Microsoft Windows
1.1.8
SGI
1.1.8-00
Sun Solaris
1.1.8-09a

To see the Java version used by MATLAB, type version -java in the command window.

New C Language mx Functions

The following mx functions are new in this release.

Function
Purpose
mxCreateNumericMatrix
Create a numeric matrix and initialize all its data elements to 0
mxCreateScalarDouble
Create a scalar, double-precision array initialized to the specified value

Additional Supported Compilers

MATLAB now includes preconfigured options files for these compilers:

Using the Add-In for Visual Studio

The MathWorks provides a MATLAB add-in for the Visual Studio® development system that lets you work easily within Microsoft Visual C/C++ (MSVC). The MATLAB add-in for Visual Studio greatly simplifies using M-files in the MSVC environment. The add-in automates the integration of M-files into Visual C++ projects. It is fully integrated with the MSVC environment.

The add-in for Visual Studio is automatically installed on your system when you run either mbuild -setup or mex -setup and select Microsoft Visual C/C++ version 5 or 6.

However, there are several steps you must follow in order to use the add-in:

  1. To build MEX-files with the add-in for Visual Studio, run the following command at the MATLAB command prompt.
  1. Follow the menus and choose either Microsoft Visual C/C++ 5.0 or 6.0. This configures mex to use the selected Microsoft compiler and also installs the necessary add-in files in your Microsoft Visual C/C++ directories.

  1. To configure the MATLAB add-in for Visual Studio to work with Microsoft Visual C/C++:
    1. Select Tools -> Customize from the MSVC menu.
    2. Click on the Add-ins and Macro Files tab.
    3. Click Browse, type <matlab>\bin\win32 as the filename, and select Add-ins (.dll) from the Files of Type pulldown list.

    1. Select the MATLABAddin.dll file and click Open.
    2. Check MATLAB for Visual Studio on the Add-ins and Macro Files list and click Close. The floating MATLAB add-in for Visual Studio toolbar appears. The checkmark directs MSVC to automatically load the add-in when you start MSVC again.

For additional information on the MATLAB add-in for Visual Studio:

Command Line Override

To specify an option on a one-time basis to the mex script, you can use the mex command line override feature. For example, the string /WX is a Microsoft Visual C/C++ compiler option that causes warnings to be treated as errors. The following statement uses the mex command line override feature.

The string COMPFLAGS#"$COMPFLAGS /WX" tells mex to take the default value for COMPFLAGS and append /WX (space slash W X) to it. To get a list of all environment variables that can be overridden using this feature, use the command

Any variable name in all uppercase listed in the output can be overridden.

Serial I/O

The MATLAB serial port interface provides direct access to peripheral devices such as modems, printers, and scientific instruments that you connect to your computer's serial port. This interface is established through a serial port object, which you create with the serial function. The serial port object supports functions and properties that allow you to


  3-D Visualization Features Creating Graphical User Interfaces - Features