Graphics Previous page   Next Page

Using Character and Numeric Variables in Text

Any string variable is a valid specification for the text String property. This section illustrates how to use matrix, cell array, and numeric variables as arguments to the text function.

Character Variables

For example, each row of the matrix PersonalData contains specific information about a person (note that all but the longest row are padded with a space so that each has the same number of columns).

PersonalData = ['Jack Straw  ';'489 Main St.';'Wichita KN '];

To display the data, index into the desired row.

Cell Arrays

Using a cell array enables you to create multiline text with a single text object. Each cell does not need to be the same number of characters. For example, the following statements,

produce this output.

Numeric Variables

You can specify numeric variables in text strings using the num2str (number to string) function. For example, if you type on the command line

MATLAB concatenates the three separate strings into one.

Since the result is a valid string, you can specify it as a value for the text String property.


Previous page  Mathematical Symbols, Greek Letters, and TEX Characters Example -- Multiline Text Next page

© 1994-2005 The MathWorks, Inc.