Strings variables are primarily used for labeling output and
passing the names of m-files as arguments to other functions.
While strings are not usually thought of as fundamental to
numerical analysis, strings can add a degree of flexibility
and polish to your MATLAB code.
Strings are matrices with character elements. The normal rules
of assignment and variable creation apply. The simplest way to
create a string is to use it on the left side of an equal sign
where the right side of the equal sign is an expression that
evaluates to a string.
String constants (literals) are enclosed in single quotes. The
following example shows how to create string variables.
>> first = 'John';
>> last = 'Coltrane';
>> name = [first,' ',last]
The first two lines define two string variables. The last line
creates a new string variable from three other strings. This
assignment is the most straightforward way to concatenate two
strings.
- Comparison
- Concatenation
- Reading strings from files
- Element-wise string operations
- Passing strings to built-in functions
[Preceding Section]
[Master Outline]
[Section Outline]
[Next Section]