>> ["Entering", " ", "Rose", " ", "County"] Entering Rose County
The same can be achieved by using the addition operator. For example
>> s = "Entering" + " " + "Rose" + " " + "County" Entering Rose County
If n is a positive integer and s is a string, n * s or s * n will create a new string which is s repeated n times.
>> s = "haha ... "; >> 5 * s haha ...haha ...haha ...haha ...haha ...
If s and t are two strings of the same length, or one of them has length 1, then s - t returns a row vector of integers, which are the differences between the ASCII codes of s and t. For example
>> s = "bcdefg" - "a" 1 2 3 4 5 6 >> s = "uvwxyz" - "UVWXYZ" 32 32 32 32 32 32
If s is a string, and x is a integer scalar, or a vector of integers having the same length as x, then s + x returns a vector of the same length as s whose ASCII values are those of s plus the value(s) of x.
>> s = "BCDEFG" + 32 bcdefgNote s - x and x - x are defined in the same manner.
>> s = "bounding" - ("a" - "A") BOUNDINGWhen numbers or vectors are being added to or subtracted from a string, the resulting must still have characters within the range of ASCII values. Otherwise the operation is not carried out.
oz 2009-12-22