MATLAB 5.2 Product Family New Features     Search    Help Desk 

Chapter 2
MATLAB 5.1 Enhancements


What's New in MATLAB 5.1? 

Language and Development Environment
Enhancements 

Handle Graphics Enhancements 

TIFF and JPEG Device Drivers 

TIFF Preview Images for Encapsulated PostScript 

API Enhancements for Windows NT 

API Enhancements for Macintosh 

Stateflow 

Mapping Toolbox 


What's New in MATLAB 5.1?

Note: All the features introduced in MATLAB 5.1 are also in MATLAB 5.2.

The main purpose of the MATLAB 5.1 release was to complete upgrades to the 5.0 level of the entire set of toolboxes and blocksets, and to introduce the Stateflow product. However, there were also a number of small but useful enhancements to MATLAB provided with this release.

Enhancements to MATLAB

MATLAB 5.1 added several enhancements to the MATLAB language and development environment, Handle Graphics®, printing, and the Application Program Interface (API).

The language and development environment enhancements included:

The Handle Graphics and printing enhancements included:

The Application Program Interface enhancements included:

MATLAB 5.1 also fixed bugs from earlier releases either reported by customers or found through additional internal testing.

Upgrades to Simulink, Real-Time Workshop, Toolboxes, and Blocksets

MATLAB 5.1 completed the upgrades to the entire set of toolboxes. The Fixed-Point Blockset 1.0.2 was introduced with MATLAB 5.1.

New releases of the following products were also produced with MATLAB 5.1; however, these products have been upgraded once again for MATLAB 5.2 (the MATLAB 5.2 version number is shown, since that is the version that is shipped with MATLAB 5.2):

New Products

In addition to these toolboxes, two new products were introduced with MATLAB 5.1:

Stateflow and the Mapping Toolbox are described in more detail below.

Language and Development Environment Enhancements

find Returns Empty Matrix

The find function returns an empty matrix if nothing is found. Previously it returned [0,1].

Multibyte Character Support

On the PC and Macintosh, MATLAB 5.1 added support for multibyte characters (including Kanji) for data.

This feature allows you to use multibyte characters in MATLAB strings. You can also use multibyte characters in Handle Graphics property values and Simulink blocks.

Note that you cannot use multibyte characters in variable, file, or function names. Also, multibyte text may not be machine independent.


Removal of Microsoft Windows TCP/IP Issues

MATLAB 5.0 for Microsoft Windows 95 required the use of TCP/IP networking software even for non-networked installations. For MATLAB 5.1 this requirement was removed. The portions of the MATLAB user interface that depended upon TCP/IP were recoded to use ActiveX.


Notebook Support for Office 97

MATLAB 5.1 provided Notebook support for Microsoft Office 97.

Note: The MATLAB 5.1 Notebook worked with Windows NT with Microsoft Office 97. However, for Windows 95, due to an Office 97 problem, you may experience problems printing a Notebook document that includes an imported graphic. See "OFF97: Imported EMF Files Are Not Printed Correctly" in the online Microsoft Knowledge Base for details.


PC Editor/Debugger

For MATLAB 5.1 the PC Editor/Debugger provided new debugging icons on the toolbar. The debugging operations are the same as for MATLAB 5.0. The new debugging icons on the toolbar were:

Toolbar
Button
Description Equivalent
Command


Set/Clear Breakpoint: set or clear a breakpoint at the line containing the cursor.

dbstop/dbclear


Clear All Breakpoints: clear all breakpoints that are currently set.

dbclear all


Step In: execute the current line of the M-file and if the line is a call to another function, step into that function.

dbstep in


Single Step: execute the current line of the M-file.

dbstep


Continue: continue execution of M-file until completion or until another breakpoint is encountered.

dbcont


Quit Debugging: exit the debugging state.

dbquit




Editing Arrays on Macintosh

MATLAB 5.1 provided a new capability to allow you to view and edit two-dimensional real and complex double arrays, row vector character arrays, and row or column vector cell arrays of strings. If the Array Editor does not support a variable type, double-click on the variable in the Workspace Browser to display the variable in the Command Window. This tool can be especially useful when debugging M-functions using the M-file Debugger.

An example of the Array Editor is shown below.

For numeric arrays, the pull-down menu allows you to change the format of the output display as if you were using the format command.



The Path Browser on the Macintosh

In MATLAB 5.1, if you change the path from the Command Window, the Path Browser's contents update automatically. The Refresh button was removed from the Path Browser.

If you check the Add subfolders box, all subfolders of the selected directory will be added to the path as well.


Macintosh Debugger

The MATLAB 5.1 Debugger provided a new operation, Step Out, which was represented by a new icon on the debugger toolbar. The full set of debugging icons is:

Toolbar
Button
Description Equivalent
Command

Single Step: execute the current line of the M-file.

dbstep

Step In: execute the current line of the M-file and if the line is a call to another function, step into that function.

dbstep in

Step Out: continue execution until a return to the calling function is encountered.

 

Continue: continue execution of M-file until completion or until another breakpoint is encountered.

dbcont

Quit Debugging: exit the debugging state.

dbquit

The 5.1 Debugger also introduced the Go Until Here menu item on the Debug menu. If you place the cursor at a specific line and choose the menu item, execution continues until that line is reached. Option-click on the breakpoint marker to the left of a line to execute a shortcut for this operation.

Handle Graphics Enhancements

MATLAB 5.1 provided some new Handle Graphics functions.

Scatter Plot Functions Added

MATLAB added two new functions, scatter and scatter3, which enable you to create two-dimensional and three-dimensional scatter plots. Each function allows you to specify the style, size, and color of the marks used to create the scatter diagrams.

See the online MATLAB Function Reference for more information about these functions.

X-Windows Support for uisetcolor

The uisetcolor function is supported on X-Windows systems (UNIX).

Previously Undocumented Functions

These two functions existed in MATLAB 5.0, with command line help, but were not documented in the MATLAB 5.0 online Function Reference; they are documented in the MATLAB 5.2 online Function Reference:

Printing Patches and Surfaces

MATLAB 5.1 added support for printing texture-mapped patches and surfaces (this did not work in Version 5.0).

Also, printing interpolated patches and surfaces is more efficient than in Version 5.0.

TIFF and JPEG Device Drivers

MATLAB 5.1 added new built-in device drivers for producing TIFF (Tagged Image File Format) and JPEG (Joint Photographic Experts Group) graphics files from MATLAB figures. These drivers are available on all platforms.

This table summarizes the command-line switches for these drivers:

Device
Description
-dtiff
TIFF with packbit compression
-dtiffnocompression
TIFF with no compression
-djpeg
Baseline JPEG, quality level 75
-djpegnumber
Baseline JPEG, quality level specified by number

Note: These drivers work with MATLAB figures only. You cannot use these drivers to print Simulink models.

This section summarizes how to use these drivers with the print command.

TIFF

To produce a TIFF file from a MATLAB figure, use the -dtiff switch. For example, this command produces a TIFF file named newplot.tif from the current figure:

You can use the -r option in conjunction with the -dtiff switch to specify the resolution of the output. For example:

If you do not specify the resolution, MATLAB uses the default resolution of 150 dots per inch.

Note that you must specify a filename because TIFF files cannot be sent directly to a printer. If you omit the filename, MATLAB assigns the file a name, such as figure1.tif. If you specify a filename that does not include the .tif extension, MATLAB appends the extension automatically.

The TIFF files that MATLAB produces are 24-bit truecolor bitmaps. MATLAB renders these graphics using the Z-buffer renderer, regardless of the setting of the figure Renderer property. If you use the -painters switch with the print command, the switch is ignored.

Compression

The TIFF output produced by -dtiff uses packbit compression, a lossless compression scheme that is supported by virtually all applications that can import TIFF graphics. If you need to import a TIFF file into an application that does not read packbit-compressed TIFF, use the -dtiffnocompression switch to produce an uncompressed TIFF file. (You can abbreviate this switch to
-dtiffn.) For example:

An uncompressed TIFF file is often much larger than the same file compressed. For certain plots, the uncompressed file may be more than 10 times the size of the compressed file. (The actual ratio will vary. The size of an uncompressed file depends only on the resolution and the width and height values in the PaperPosition figure property; the size of the compressed file also depends on the content of the figure.)

JPEG

To produce a JPEG file from a MATLAB figure, use the -djpeg switch. For example, this command produces a JPEG file named newplot.jpg from the current figure:

You can you use the -r option in conjunction with the -djpeg switch to specify the resolution of the output. For example:

If you do not specify the resolution, MATLAB uses the default resolution of 150 dots per inch.

Note that you must specify a filename because JPEG files cannot be sent directly to a printer. If you omit the filename, MATLAB assigns the file a name such as figure1.jpg. If you specify a filename that does not include the .jpg extension, MATLAB appends the extension automatically.

The JPEG files that MATLAB produces are 24-bit truecolor bitmaps. MATLAB renders these graphics using the Z-buffer renderer, regardless of the setting of the figure Renderer property. If you use the -painters switch with the print command, the switch is ignored.

Compression

JPEG files use a lossy compression scheme that compresses files dramatically with relatively little loss of information. This scheme enables you to make tradeoffs between file size and quality, by specifying a quality level between 0 (minimum quality, maximum compression) and 100 (maximum quality, minimum compression). By default, -djpeg uses a quality level of 75; however, you can use a different level by appending the value to the device name. For example, this command produces a JPEG file with a quality level of 50:

Even at the highest quality level, JPEG files are often highly compressed. In fact, depending on the figure, a JPEG file with a quality level of 100 may be considerably smaller than a packbit-compressed TIFF file of the same figure.

TIFF Preview Images for Encapsulated PostScript

MATLAB 5.1 introduced support for TIFF preview images for Encapsulated PostScript (EPS) files. To produce a TIFF preview, use the -tiff switch. For example, this command creates an EPS file called newplot.eps that contains a TIFF preview:

The preview image has a resolution of 72 dots per inch, and the colors in the preview match the colors in the EPS file. MATLAB creates the EPS with a loose bounding box (i.e., white space around the figure), so that the size and position of the preview image match the EPS. There may be some differences between the EPS and the TIFF preview because the preview is always rendered using Z-buffer, while the EPS may be rendered with painter's algorithm.

The -tiff switch works on all platforms; you can view the resulting preview image within any application that can display TIFF graphics.

Alternate Method on the Macintosh

On Macintosh systems, you can also specify a TIFF preview image by selecting Save As from the File menu of the figure window. In the dialog box, use the File Type pop-up menu to select an EPS format, and then select TIFF from the Preview pop-up menu.

Also on Macintosh systems, if you use the print command to create an EPS file and you do not use the -tiff switch, the file is created with a PICT preview. On other platforms, no preview is created.

API Enhancements for Windows NT

Setting Up the Compiler Location

MATLAB 5.1 provided a new switch for the mex script. The switch, setup, allows you to configure the default options file, mexopts.bat, for your system C compiler. This eliminates the need to reinstall MATLAB if you change compilers for your environment.

You can run the setup option from either the MATLAB or DOS command prompt, and it can be called anytime to configure the options file.

Executing the setup option presents a list of compilers whose options files are currently shipped in the bin subdirectory of MATLAB. This example shows how to select the Microsoft Visual C++ compiler:

If the selected compiler has more than one options file (due to more than one version of the compiler), you are asked for a specific version. For example,

Finally, you are asked to enter the location of your compiler:

API Enhancements for Macintosh

Installation Notes for Using CodeWarrior 11 with the MATLAB API

MATLAB 5.1 introduced support for CodeWarrior 10. CodeWarrior 11 is supported with the limitations described below. Previous versions of CodeWarrior are not supported.

In CodeWarrior 11, Metrowerks introduced a new ANSI C library, known as the Metrowerks Standard Library (MSL). Based on difficulties involved in upgrading to MSL, and from similar USENET reports of MSL bugs, MATLAB Application Program Interface (API) support for MSL has been postponed until a future version of CodeWarrior is released.

To use CodeWarrior 11 to generate MEX-files and/or MAT applications, you must install the old CodeWarrior libraries and header files. These files are the same as those shipped with previous versions of CodeWarrior, and can be found on the CodeWarrior 11 CD-ROM in the folder

The names of the folders within (Obsolete ANSI Libraries) indicate the CodeWarrior folder to which their contents should be copied.

Using CodeWarrior 10 and 11 with the MATLAB API

The instructions below supersede the instructions for building MAT-file programs when using CodeWarrior 10 and 11 that are given in Chapter 4 of the MATLAB Application Program Interface Guide.

Building Applications on the Power Macintosh and 68K Macintosh

To build applications that use the MAT-file API, start with a project made from the stationery MATLAB_API_App.PPC.proj (for Power Macintoshes) or MATLAB_API_App.68k.proj (for 68K Macintoshes) in the <MATLAB>:extern:src: folder. Then, make these modifications to your project:

   1.
In the Access Paths preference panel, add to the User field the folder
   2.
Add the source files that call MAT-file API functions to the project.
   3.
On Power Macintoshes, add to the project the shared libraries libmx and libmat from the <MATLAB>extern:lib:PowerMac:
On 68K Macintoshes, add the static libraries libmx.lib, libmi.lib, libut.lib, and libmat.lib from the <MATLAB>:extern:lib:68k:Metrowerks: folder to the project.
You can now build and link your project as normally done in CodeWarrior.

Stateflow

Addition to the Simulink Modeling Environment

Stateflow was introduced with MATLAB 5.1 adding to the Simulink modeling and simulation environment. A graphical tool for designing complex control and supervisory logic systems, Stateflow allows you to model and simulate the behavior of complex reactive, event-based systems based on finite state machine theory. Stateflow lets you add event-driven elements of a system to Simulink continuous or discrete modeling for a single, closed-loop simulation.

Stateflow represents an evolution from finite state machine theory by adding several major improvements, including hierarchy, parallelism, junctions, and history. These changes enable Stateflow to make practical use of finite state machine theory with realistic application to control systems.

A major benefit of Stateflow is its seamless point-and-click interface to Simulink. The control behavior that Stateflow models provides an ideal complement to the algorithmic behavior modeled in Simulink. In Simulink, you develop your model of continuous- and discrete-time dynamic systems using its graphical, block diagram environment. Then you drag and drop the blocks that represent Stateflow diagrams directly into your Simulink model to add event-driven behavior to Simulink simulations.

Applications for Stateflow include developing the control logic in embedded systems for electronic and mechanical systems found in automobiles, aircraft, telecommunications systems, computer peripherals, office automation equipment, and medical instrumentation.

Stateflow works with the latest versions of Simulink and Real-Time Workshop to offer an integrated environment for modeling, simulating, and prototyping real-time embedded systems applications.

Stateflow Coder

Stateflow provides automatic C-code generation through the optional Stateflow Coder. C code generated by Stateflow Coder can be used independently or integrated with code from Real-Time Workshop. Thus, Simulink, Stateflow, and Real-Time Workshop are integrated from the design and modeling phase through the code generation stage. The generated code can be executed for rapid prototyping, hardware-in-the-loop testing, or for stand-alone simulations.

Mapping Toolbox

The Mapping Toolbox was introduced with MATLAB 5.2, providing a toolbox for geographic display and cartographic analysis. The toolbox gives you the ability to plot geographically based information as easily as any other type of data that you can plot in MATLAB. Both vector and matrix map data can be displayed, manipulated, and analyzed. The toolbox manages the projection, clipping, and trimming of the data automatically for you, even if you change the projection.

The Mapping Toolbox provides more than 60 map projections. There are extensive geographic analysis functions, such as computations of distance, tracks, great and small circles, intersections, and navigation functions. These computations can be made for a spherical body, or can make use of spheroidal models of the earth and other planets when more accuracy is required. Utility functions allow you to convert easily between different time, distance, and angle units.

The toolbox provides a number of global map data sets, and allows you to import more detailed data from government sources over the Internet and on CD-ROM. These data sets include the Digital Chart of the World, Tiger/Line files, and Digital Elevation Models of the world and the United States.

In addition to the command-line functions, the toolbox also provides an extensive suite of graphical user interfaces (GUIs) for accessing the toolbox functionality. These GUIs allow you to manage data interactively, plot it, modify the display, make measurements, and generate geographic data like tracks and circles. The GUIs are available as an integrated set and also are available individually.



[ Previous | Help Desk | Next ]