Characters and Strings
Text in character arrays and string arrays
Character arrays and string arrays provide storage for text data in MATLAB®.
-
A character array is a sequence of characters, just as a numeric array is a sequence of numbers. A typical use is to store short pieces of text as character vectors, such as c = 'Hello World'
.
-
A string array is a container for pieces of text. String arrays provide a set of functions for working with text as data. Starting in R2017a, you can create strings using double quotes, such as str = "Greetings friend"
. To convert data to string arrays, use the string
function.
For more information, see Text in String and Character Arrays or watch Using String Arrays for Text Data.
Functions
Create, Concatenate, and Convert
String Arrays
string |
String array |
strings |
Create string array with no characters |
join |
Combine strings |
Character Arrays
char |
Character array |
cellstr |
Convert to cell array of character vectors |
blanks |
Create character array of blanks |
newline |
Create newline character |
Character or String Arrays
compose |
Format data into multiple strings |
sprintf |
Format data into string or character vector |
strcat |
Concatenate strings horizontally |
append |
Combine strings |
Convert Input Arguments
Convert Between Numeric and Strings
double |
Double-precision arrays |
string |
String array |
str2double |
Convert strings to double precision values |
num2str |
Convert numbers to character array |
Determine Type and Properties
Data Type
ischar |
Determine if input is character array |
iscellstr |
Determine if input is cell array of character vectors |
isstring |
Determine if input is string array |
isStringScalar |
Determine if input is string array with one element |
Text Properties
strlength |
Lengths of strings |
isstrprop |
Determine which characters in input strings are of specified category |
isletter |
Determine which characters are letters |
isspace |
Determine which characters are space characters |
Find and Replace
Find
contains |
Determine if pattern is in strings |
matches |
Determine if pattern matches strings |
count |
Count occurrences of pattern in strings |
endsWith |
Determine if strings end with pattern |
startsWith |
Determine if strings start with pattern |
strfind |
Find strings within other strings |
sscanf |
Read formatted data from strings |
Replace
replace |
Find and replace one or more substrings |
replaceBetween |
Replace substrings between start and end points |
strrep |
Find and replace substrings |
Join and Split
join |
Combine strings |
split |
Split strings at delimiters |
splitlines |
Split strings at newline characters |
strjoin |
Join strings in array |
strsplit |
Split string or character vector at specified delimiter |
strtok |
Selected parts of strings |
Edit
erase |
Delete substrings within strings |
eraseBetween |
Delete substrings between start and end points |
extractAfter |
Extract substrings after specified positions |
extractBefore |
Extract substrings before specified positions |
extractBetween |
Extract substrings between start and end points |
insertAfter |
Insert strings after specified substrings |
insertBefore |
Insert strings before specified substrings |
pad |
Add leading or trailing characters to strings |
strip |
Remove leading and trailing characters from strings |
lower |
Convert strings to lowercase |
upper |
Convert strings to uppercase |
reverse |
Reverse order of characters in strings |
deblank |
Remove trailing whitespace from ends of strings |
strtrim |
Remove leading and trailing whitespace from strings |
strjust |
Justify strings |
Compare
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) |
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 |
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.