Appending string to Matlab array
As other answers have noted, using cell arrays is probably the most straightforward approach, which will result in your variable name
being a cell array where each cell element contains a string.
However, there is another option using the function STRVCAT, which will vertically concatenate strings. Instead of creating a cell array, this will create a 2-D character matrix with each row containing one string. STRVCAT automatically pads the ends of the strings with spaces if necessary to correctly fill the rows of the matrix:
>> string1 = 'hi';>> string2 = 'there';>> S = strvcat(string1,string2)S =hithere