This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

Characters and Strings

Text in character arrays

Character arrays provide storage for text data in MATLAB®.

  • Store text by enclosing a sequence of characters in single quotation marks, such as chr = 'name';.

  • Store several separate pieces of text in one collection by using a cell array, such as C = {'firstname','lastname'};.

You can combine and split character arrays, find and replace substrings within them, and compare them to one another.

For more information, see Create Character Arrays and Cell Arrays of Character Vectors.


Create and Concatenate Arrays of Text

blanks Create character array of blanks
cellstr Convert to cell array of character vectors
char Convert to character array
iscellstr Determine whether input is cell array of character vectors
ischar Determine whether item is character array
sprintf Format data into string
strcat Concatenate strings horizontally
strjoin Join strings in cell array into single string

Find and Replace Text

ischar Determine whether item is character array
isletter Array elements that are alphabetic letters
isspace Array elements that are space characters
isstrprop Determine whether string is of specified category
sscanf Read formatted data from string
strfind Find one string within another
strrep Find and replace substring
strsplit Split string at specified delimiter
strtok Selected parts of string
validatestring Check validity of text
symvar Determine symbolic variables in expression

Regular Expressions

regexp Match regular expression (case sensitive)
regexpi Match regular expression (case insensitive)
regexprep Replace text using regular expression
regexptranslate Translate text into regular expression

Compare Text

strcmp Compare strings
strcmpi Compare strings (case insensitive)
strncmp Compare first n characters of strings (case sensitive)
strncmpi Compare first n characters of strings (case insensitive)

Letter Case, Blanks, and Justification

blanks Create character array of blanks
deblank Remove trailing whitespace from end of character array
strtrim Remove leading and trailing whitespace from character array
lower Convert characters to lowercase
upper Convert characters to uppercase
strjust Justify character array
Was this topic helpful?