Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
18
Добавлен:
09.02.2015
Размер:
195.07 Кб
Скачать

matlab\strfun – Функции работы со строками

General

<char> - Create character array (string).

CHAR Create character array (string).

S = CHAR(X) converts the array X that contains nonnegative integers

representing character codes into a MATLAB character array (the first

127 Codes are ascii). The actual characters displayed depends 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

may 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 pads each string with

blanks in order 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.

See also strings, double, cellstr, iscellstr, ischar.

Overloaded methods:

opaque/char

inline/char

fittype/char

codistributed/char

junit/char

cgtabgradconstraint/char

cgsumobjective/char

cgsumconstraint/char

cgrangeconstraint/char

cgprecpolyfix/char

cgpreclookupfix/char

cgprecfloat/char

cgprec/char

cgpointobjective/char

cgpointconstraint/char

cgoptimitem/char

cgoppoint/char

cgfuncmodel/char

xregdesign/char

des_constraints/char

coninputfactor/char

cgvariable/char

cgsubexpr/char

cgrelexpr/char

cgnormfunction/char

cgnormaliser/char

cgmswitchexpr/char

cgmodexpr/char

cgminmaxexpr/char

cglookuptwo/char

cglookupone/char

cgifexpr/char

cgfuncexpr/char

cgfeature/char

cgexprconstraint/char

cgexpr/char

cgdivexpr/char

cgconstraint/char

cgconconstraint/char

cgclipexpr/char

xregvectorinput/char

xregtextinput/char

xregstepinput/char

xregrangeinput/char

xreglistctrl/char

xregconstinput/char

xregclicktolinput/char

xregclickinput/char

popupinput/char

multiinput/char

xregusermod/char

xregunispline/char

xregtwostage/char

xregrbf/char

xregnnet/char

xregmulti/char

xregmodswitch/char

xregmodel/char

xreglolimot/char

xreginterprbf/char

xreghybridrbf/char

xregcubic/char

xregcovariance/char

xregarx/char

xreg3xspline/char

mbcinputfactor/char

localusermod/char

localtruncps/char

localsurface/char

localpspline/char

localpoly/char

localmulti/char

localbspline/char

localavfit/char

sweepsetfilter/char

sweepset/char

sgmltag/char

rptcp/char

categorical/char

sym/char

Reference page in Help browser

doc char

<strings> - Help for strings.

STRINGS Character strings in MATLAB.

S = 'Any Characters' creates a character array, or string. The

string is actually a vector whose components are the numeric codes

for the characters (the first 127 codes are ASCII). The actual

characters displayed depends on the character set encoding for a

given font. The length of S is the number of characters. A quote

within the string is indicated by two quotes.

S = [S1 S2 ...] concatenates character arrays S1, S2, etc. into a

new character array, S.

S = strcat(S1, S2, ...) concatenates S1, S2, etc., which can be

character arrays or cell arrays of strings. When the inputs are all

character arrays, the output is also a character array. When any of

the inputs is a cell array of strings, STRCAT returns a cell array

of strings.

Trailing spaces in STRCAT character array inputs are ignored and

do not appear in the output. This is not true for STRCAT inputs

that are cell arrays of strings. Use the S = [S1 S2 ...] concate-

nation syntax, shown above, to preserve trailing spaces.

S = CHAR(X) can be used to convert an array that contains positive

integers representing character codes into a MATLAB character array.

X = DOUBLE(S) converts the string to its equivalent double precision

numeric codes.

A collection of strings can be created in two ways: 1) as the rows of a

character array via CHAR or 2) as a cell array of strings via the

curly braces. The two are different but can be converted back and

forth with CHAR and CELLSTR. Most string functions support both

types.

ISCHAR(S) tells if S is a character array (string) and ISCELLSTR(S)

tells if S is a cell array of strings.

Examples

msg = 'You''re right!'

name = ['Thomas' ' R. ' 'Lee']

name = strcat('Thomas',' R.',' Lee')

C = char('Hello','Yes','No','Goodbye')

S = {'Hello' 'Yes' 'No' 'Goodbye'}

See also text, char, cellstr, cell, double, ischar, iscellstr, strfun,

sprintf, sscanf, input.

Reference page in Help browser

doc strings

<cellstr> - Create cell array of strings from character array.

CELLSTR Create cell array of strings from character array.

C = CELLSTR(S) places each row of the character array S into

separate cells of C.

Use CHAR to convert back.

Another way to create a cell array of strings is by using the curly

braces:

C = {'hello' 'yes' 'no' 'goodbye'};

See also strings, char, iscellstr.

Overloaded methods:

dataset/cellstr

categorical/cellstr

Reference page in Help browser

doc cellstr

<blanks> - String of blanks.

BLANKS String of blanks.

BLANKS(n) is a string of n blanks.

Use with DISP, e.g. DISP(['xxx' BLANKS(20) 'yyy']).

DISP(BLANKS(n)') moves the cursor down n lines.

See also clc, home, format.

Reference page in Help browser

doc blanks

<deblank> - Remove trailing blanks.

DEBLANK Remove trailing blanks.

R = DEBLANK(S) removes any trailing whitespace characters from string S.

A whitespace is any character for which the ISSPACE function returns

TRUE.

S can also be a cell array of strings. In this case, DEBLANK removes

trailing whitespace from each element of the cell array.

INPUT PARAMETERS:

S: any one of a char row vector, char array, or a cell array of strings.

RETURN PARAMETERS:

R: any one of a char vector, char array or a cell array of strings.

EXAMPLES:

A{1,1} = 'MATLAB ';

A{1,2} = 'SIMULINK ';

A = deblank(A)

A =

'MATLAB' 'SIMULINK'

See also isspace, cellstr, strtrim.

Reference page in Help browser

doc deblank

String tests

<iscellstr> - True for cell array of strings.

ISCELLSTR True for cell array of strings.

ISCELLSTR(S) returns 1 if S is a cell array of strings and 0

otherwise. A cell array of strings is a cell array where

every element is a character array.

See also cellstr, iscell, char, ischar.

Reference page in Help browser

doc iscellstr

<ischar> - True for character array (string).

ISCHAR True for character array (string).

ISCHAR(S) returns 1 if S is a character array and 0 otherwise.

See also char, isnumeric, islogical, isobject, isjava.

Reference page in Help browser

doc ischar

<isspace> - True for white space characters.

ISSPACE True for white space characters.

For a string S, ISSPACE(S) returns an array the same size as S

containing logical 1 (TRUE) where the elements of S are

Unicode-represented whitespace characters and logical 0 (FALSE) where

they are not.

White space characters for which ISSPACE returns TRUE include tab, line

feed, vertical tab, form feed, carriage return, and space, in addition

to a number of other Unicode characters.

Example

isspace(' Find spa ces ')

Columns 1 through 13

1 1 0 0 0 0 1 0 0 0 1 0 0

Columns 14 through 15

0 1

See also isletter.

Overloaded methods:

opaque/isspace

Reference page in Help browser

doc isspace

<isstrprop> - Check if string elements are of a specified category.

ISSTRPROP Check if string elements are of a specified category.

B = ISSTRPROP(S,C) returns in B the logical array of the same shape as S,

confirming whether the elements of S are of string category C. The type of

S may be any of a cell array, char or any of the MATLAB numeric types. If S

is a cell array, then B is a cell array of the same shape as S. The

classification of elements of S are done according to the Unicode definition

of the specified category. That is, if the numeric value of an element in

the input array falls within the range that defines a Unicode character

category, then this element is classified as of that category. The set of

Unicode character codes includes the set ASCII character codes, but covers a

large number of languages beyond the scope of the ASCII set. The

classification of characters is subject to the locale setting of MATLAB.

INPUT ARGUMENTS

S can be any of type char, int8, uint8, int16, uint16, int32, uint32, int64,

uint64, double, cell array. A cell array may contain arrays of the

aforementioned types.

Numbers of type double are converted to int32 according to MATLAB rules of

double-to-int conversion. Numbers of type int64 and uint64 bigger than

int32(inf) saturates to int32(inf).

Argument C must be a string from the following set:

'alpha' : classify S as in the alphabetic letter range

'alphanum' : classify S as in the alphanumeric range

'cntrl' : classify S as in the range of control characters, char(0:20).

'digit' : classify S as in the range of numeric digits

'graphic' : classify S as in the range of graphic characters. These are

all values that represent characters NOT of the set

{unassigned, space, line separator, paragraph separator, control

characters, Unicode format control characters, private

user-defined characters, Unicode surrogate characters, Unicode

other characters}.

'lower' : classify S as in the range of lowercase letters

'print' : classify S as in the range of graphic characters, plus

char(32).

'punct' : classify S as in the range of punctuation characters

'wspace' : classify S as in the range of whitespace characters; this

range includes the ANSI C definition of whitespace,

{' ','\t','\n','\r','\v','\f'}, in addition to a number of

other Unicode characters.

'upper' : classify S as in the range of uppercase letters

'xdigit' : classify S as in the range of valid hexadecimal digits

EXAMPLES

B = isstrprop('abc123efg','alpha') returns B => [1 1 1 0 0 0 1 1 1]

B = isstrprop('abc123efg','digit') returns B => [0 0 0 1 1 1 0 0 0]

B = isstrprop('abc123efg','xdigit') returns B => [1 1 1 1 1 1 1 1 0]

B = isstrprop([97 98 99 49 50 51 101 102 103],'digit') returns

B => [0 0 0 1 1 1 0 0 0]

B = isstrprop(int8([97 98 99 49 50 51 101 102 103]),'digit') returns

B => [0 0 0 1 1 1 0 0 0]

B = isstrprop(['abc123efg';'abc123efg'],'digit') returns

B => [0 0 0 1 1 1 0 0 0; 0 0 0 1 1 1 0 0 0]

B = isstrprop({'abc123efg';'abc123efg'},'digit') returns

B => {[0 0 0 1 1 1 0 0 0]; [0 0 0 1 1 1 0 0 0]}

B = isstrprop(sprintf('abc\n'),'wspace') returns B => [0 0 0 1]

See also ischar, isspace.

Reference page in Help browser

doc isstrprop

Соседние файлы в папке Библиотеки Matlab