23.12.2012 Views

MATLAB Function Reference Volume 1: A - E - Bad Request

MATLAB Function Reference Volume 1: A - E - Bad Request

MATLAB Function Reference Volume 1: A - E - Bad Request

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2char<br />

Purpose Create character array (string)<br />

Syntax S = char(X)<br />

S = char(C)<br />

S = char(t1,t2,t3...)<br />

Description S = char(X) converts the array X that contains positive integers representing<br />

character codes into a <strong>MATLAB</strong> character array (the first 127 codes are<br />

ASCII). The actual characters displayed depend on the character set encoding<br />

for a given font. The result for any elements of X outside the range from 0 to<br />

65535 is not defined (and may vary from platform to platform). Use double to<br />

convert a character array into its numeric codes.<br />

S = char(C) when C is a cell array of strings, places each element of C into the<br />

rows of the character array s. Use cellstr to convert back.<br />

S = char(t1,t2,t3,..) forms the character array S containing the text<br />

strings T1,T2,T3,... as rows, automatically padding each string with blanks to<br />

form a valid matrix. Each text parameter, Ti, can itself be a character array.<br />

This allows the creation of arbitrarily large character arrays. Empty strings<br />

are significant.<br />

Remarks Ordinarily, the elements of A are integers in the range 32:127, which are the<br />

printable ASCII characters, or in the range 0:255, which are all 8-bit values.<br />

For noninteger values, or values outside the range 0:255, the characters<br />

printed are determined by fix(rem(A,256)).<br />

Examples To print a 3-by-32 display of the printable ASCII characters:<br />

ascii = char(reshape(32:127,32,3)')<br />

ascii =<br />

! ” # $ % & ' ( ) ∗ + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ?<br />

@ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _<br />

' a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~<br />

char<br />

2-239

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!