char - Convert to character array (string)

Syntax

S = char(X)
S = char(C)
S = char(t1, t2, t3, ...)

Description

S = char(X) converts the array X that contains nonnegative integers representing character codes into a MATLAB character array. The actual characters displayed depend on the character encoding scheme for a given font. The result for any elements of X outside the range from 0 to 65535 is not defined (and can vary from platform to platform). Use double to convert a character array into its numeric codes.

S = char(C), when C is a cell array of strings, places each element of C into the rows of the character array s. Use cellstr to convert back.

S = char(t1, t2, t3, ...) forms the character array S containing the text strings T1, T2, T3, ... as rows, automatically padding each string with blanks to form a valid matrix. Each text parameter, Ti, can itself be a character array. This allows the creation of arbitrarily large character arrays. Empty strings are significant.

Examples

To print a 3-by-32 display of the printable ASCII characters,

ascii = char(reshape(32:127, 32, 3)')
ascii =
   !"#$%&'()*+,-./0123456789:;<=>?
  @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
  'abcdefghijklmnopqrstuvwxyz{|}~

See Also

ischar, isletter, isspace, isstrprop, cellstr, iscellstr, get, set, strings, strvcat, text

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS