Upgrading from MATLAB 4 to MATLAB 5.0     Search    Help Desk 

New and Enhanced Handle Graphics Features

MATLAB 5.0 provided significant improvements to Handle Graphics. For details on MATLAB graphics features, see Using MATLAB Graphics.

Plotting Capabilities

MATLAB's basic plotting capabilities have been improved and expanded in MATLAB 5.0.

Table 1-18: New and Enhanced Plotting Capabilities
Function
Description
area
Filled area plot.
bar3
Vertical 3-D bar chart.
bar3h
Horizontal 3-D bar chart.
barh
Horizontal bar chart.
pie
Pie chart.
pie3
Three-dimensional pie chart.
plotyy
Plot graphs with Y tick labels on left and right.

Filling Areas

The area function plots a set of curves and fills the area beneath the curves.

Bar Chart Enhancements

bar3, bar3h, and barh draw vertical and horizontal bar charts. These functions, together with bar, support multiple filled bars in grouped and stacked formats.

Labels for Patches and Surfaces

legend can label any solid-color patch and surface. You can now place legends on line, bar, ribbon, and pie plots, for example.

Table 1-19: New Graph Annotation Functions
Function
Description
box
Axes box.
datetick
Display dates for axes tick labels.

Marker Style Enhancement

A number of new line markers are available, including, among others, a square, a diamond, and a five-pointed star. These can be specified independently from line style.

Stem Plot Enhancements

stem and stem3 plot discrete sequence data as filled or unfilled stem plots.

Three-Dimensional Plotting Support

quiver3 displays three-dimensional velocity vectors with (u,v,w) components. The ribbon function displays data as three-dimensional strips.

Table 1-20: New Three-Dimensional Plotting Functions
Function
Description
quiver3
Three-dimensional quiver plot.
ribbon
Draw lines as 3-D strips.
stem3
Three-dimensional stem plot.

Data Visualization

MATLAB 5.0 introduced many new and enhanced capabilities for data visualization.

New Viewing Model

Axes camera properties control the orthographic and perspective view of the scene created by an axes and its child objects. You can view the axes from any location around or in the scene, as well as adjust the rotation, view angle, and target point.

New Method for Defining Patches

You can define a patch using a matrix of faces and a matrix of vertices. Each row of the face matrix contains indices into the vertex matrix that define the connectivity of the face. Defining patches in this way reduces memory consumption because you no longer need to specify redundant vertices.

Triangular Meshes and Surfaces

The new functions trimesh and trisurf create triangular meshes and surfaces from x, y, and z vector data and a list of indices into the vector data.

Table 1-21: New Triangular Mesh and Surface Functions
Function
Description
trisurf
Triangular surface plot.
trimesh
Triangular mesh plot.

Improved Slicing

slice now supports an arbitrary slicing surface.

Contouring Enhancements

The contouring algorithm now supports parametric surfaces and contouring on triangular meshes. In addition, clabel rotates and inserts labels in contour plots.

Table 1-22: New Contour Plot
Function
Description
contourf
Filled contour plot.

New zoom Options

The zoom function supports two new options:

Graphics Presentation

MATLAB 5.0 provided improved control over the display of graphics objects.

Enhancements to Axes Objects

MATLAB 5.0 added more advanced control for three-dimensional axes objects. You can control the three-dimensional aspect ratio for the axes' plot box, as well as for the data displayed in the plot box. You can also zoom in and out from a three-dimensional axes using viewport scaling and axes camera properties.

The axis command supports a new option designed for viewing graphics objects in 3-D:

This option prevents MATLAB from stretching the axes to fit the size of the Figure window and otherwise altering the proportions of the objects as you change the view.

In a two-dimensional view, you can display the x-axis at the top of an axes and the y-axis at the right side of an axes.

Color Enhancements

colordef white or colordef black changes the color defaults on the root so that subsequent figures produce plots with a white or black axes background color. The figure background color is changed to be a shade of gray, and many other defaults are changed so that there will be adequate contrast for most plots. colordef none sets the defaults to their MATLAB 4 values. In addition, a number of new colormaps are available.

Table 1-23: New Figure and Axis Color Control
Function
Description
colordef
Select figure color scheme.
Table 1-24: New Colormaps
Function
Description
autumn
Shades of red and yellow colormap.
colorcube
Regularly spaced colors in RGB colorspace, plus more steps of gray, pure red, pure green, and pure blue.
lines
Colormap of colors specified by the axes' ColorOrder property.
spring
Shades of magenta and yellow colormap.
summer
Shades of green and yellow colormap.
winter
Shades of blue and green colormap.

Text Object Enhancements

MATLAB 5.0 supports a subset of TeX commands. A single text graphics object can support multiple fonts, subscripts, superscripts, and Greek symbols. See the text function in the online MATLAB Function Reference for information about the supported TeX subset.

You can also specify multiline character strings and use normalized font units so that text size is a fraction of an axes' or uicontrol's height. MATLAB supports multiline text strings using cell arrays. Simply define a string variable as a cell array with one line per cell.

Improved General Graphics Features

The MATLAB startup file sets default properties for various graphics objects so that new figures are aesthetically pleasing and graphs are easier to understand.

Table 1-25: New Figure Window Creation and Control Command
Command
Description
dialog
Create a dialog box.

Z-buffering is now available for fast and accurate three-dimensional rendering.

MATLAB 5.0 provided built-in menus on X Window systems. Figure MenuBar 'figure' is now supported on UNIX.

Lighting

MATLAB added support for a new graphics object called a light. You create a light object using the light function. Three important light object properties are:

You cannot see light objects themselves, but you can see their effect on any patch and surface objects present in the same axes. You can control these effects by setting various patch and surface object properties. AmbientStrength, DiffuseStrength, and SpecularStrength control the intensity of the respective light-reflection characteristics; SpecularColorReflectance and SpecularExponent provide additional control over the reflection characteristics of specular light.

The Axes AmbientLightColor property determines the color of the ambient light, which has no direction and affects all objects uniformly. Ambient light effects occur only when there is a visible light object in the axes.

The light object's Color property determines the color of the directional light, and its Style property determines whether the light source is a point source (Style set to local), which radiates from the specified position in all directions, or a light source placed at infinity (Style set to infinite), which shines from the direction of the specified position with parallel rays.

You can also select the algorithm used to calculate the coloring of the lit objects. The patch and surface EdgeLighting and FaceLighting properties select between no lighting, and flat, Gouraud, or Phong lighting algorithms.

print Command Revisions

The print command was extensively revised for MATLAB 5.0. Consult Using MATLAB Graphics for a complete description of print command capabilities. Among the new options available for MATLAB 5.0:

Additional print Device Options

The print command has several new device options.

Table 1-26: print Command Device Options  
Device
Description
-dljet4
HP LaserJet 4 (defaults to 600 dpi)
-ddeskjet
HP DeskJet and DeskJet Plus
-ddjet500
HP Deskjet 500
-dcdj500
HP DeskJet 500C
-dcdj550
HP Deskjet 550C
-dpjxl
HP PaintJet XL color printer
-dpjxl300
HP PaintJet XL300 color printer
-ddnj650c
HP DesignJet 650C
-dbj200
Canon BubbleJet BJ200
-dbjc600
Canon Color BubbleJet BJC-600 and BJC-4000
-dibmpro
IBM 9-pin Proprinter
-dbmp256
8-bit (256-color) BMP file format
-dbmp16m
24-bit BMP file format
-dpcxmono
Monochrome PCX file format
-dpcx24b
24-bit color PCX file format, three 8-bit planes
-dpbm
Portable Bitmap (plain format)
-dpbmraw
Portable Bitmap (raw format)
-dpgm
Portable Graymap (plain format)
-dpgmraw
Portable Graymap (raw format)
-dppm
Portable Pixmap (plain format)
-dppmraw
Portable Pixmap (raw format)

Image Support

MATLAB 5.0 made a number of enhancements to image support. These enhancements include:

Truecolor

In addition to indexed images, in which colors are stored as an array of indices into a colormap, MATLAB 5.0 now supports truecolor images. A truecolor image does not use a colormap; instead, the color values for each pixel are stored directly as RGB triplets. In MATLAB, the CData property of a truecolor image object is a three-dimensional (m-by-n-by-3) array. This array consists of three m-by-n matrices (representing the red, green, and blue color planes) concatenated along the third dimension.

Reading and Writing Images

The imread function reads image data into MATLAB arrays from graphics files in various standard formats, such as TIFF. You can then display these arrays using the image function, which creates a Handle Graphics image object. You can also write MATLAB image data to graphics files using the imwrite function. imread and imwrite both support a variety of graphics file formats and compression schemes.

8-Bit Images

When you read an image into MATLAB using imread, the data is stored as an array of 8-bit integers. This is a much more efficient storage method than the double-precision (64-bit) floating-point numbers that MATLAB typically uses.

The Handle Graphics image object has been enhanced to support 8-bit CData. This means you can display 8-bit images without having to convert the data to double precision. MATLAB 5.0 also supports a limited set of operations on these 8-bit arrays. You can view the data, reference values, and reshape the array in various ways. To perform any mathematical computations, however, you must first convert the data to double precision, using the double function.

Note that, in order to support 8-bit images, certain changes have been made in the way MATLAB interprets image data. This table summarizes the conventions MATLAB uses:

Image Type
Double-Precision Data
(Double Array)


8-Bit Data (uint8 Array)

Indexed (colormap)
Image is stored as a 2-D (m-by-n) array of integers in the range [1,length(colormap)]; colormap is an m-by-3 array of floating-point values in the range [0, 1].
Image is stored as a 2-D (m-by-n) array of integers in the range [0, 255]; colormap is an m-by-3 array of floating-point values in the range [0, 1]
Truecolor (RGB)
Image is stored as a 3-D (m-by-n-by-3) array of floating-point values in the range [0, 1].
Image is stored as a 3-D (m-by-n-by-3) array of integers in the range [0, 255].

Note that MATLAB interprets image data very differently depending on whether it is double precision or 8-bit. The rest of this section discusses things you should keep in mind when working with image data to avoid potential pitfalls. This information is especially important if you want to convert image data from one format to another.

Indexed Images

In an indexed image of class double, the value 1 points to the first row in the colormap, the value 2 points to the second row, and so on. In a uint8 indexed image, there is an offset; the value 0 points to the first row in the colormap, the value 1 points to the second row, and so on. The uint8 convention is also used in graphics file formats, and enables 8-bit indexed images to support up to 256 colors. Note that when you read in an indexed image with imread, the resulting image array is always of class uint8. (The colormap, however, is of class double; see below.)

If you want to convert a uint8 indexed image to double, you need to add 1 to the result. For example:

To convert from double to uint8, you need to first subtract 1, and then use round to ensure all the values are integers:

The order of the operations must be as shown in these examples, because you cannot perform mathematical operations on uint8 arrays.

When you write an indexed image using imwrite, MATLAB automatically converts the values if necessary.

Colormaps

Colormaps in MATLAB are always m-by-3 arrays of double-precision floating-point numbers in the range [0, 1]. In most graphics file formats, colormaps are stored as integers, but MATLAB does not support colormaps with integer values. imread and imwrite automatically convert colormap values when reading and writing files.

Truecolor Images

In a truecolor image of class double, the data values are floating-point numbers in the range [0, 1]. In a truecolor image of class uint8, the data values are integers in the range [0, 255].

If you want to convert a truecolor image from one data type to the other, you must rescale the data. For example, this call converts a uint8 truecolor image to double:

This call converts a double truecolor image to uint8:

The order of the operations must be as shown in these examples, because you cannot perform mathematical operations on uint8 arrays. When you write a truecolor image using imwrite, MATLAB automatically converts the values if necessary.



[ Previous | Help Desk | Next ]