Strings as matrix:
The matrix can be generated, that consists of strings in each row. Therefore, essentially it is created as a column vector of strings, but the final result is that this would be considered as a matrix in which each and every element is a character:
>> wordmat = ['Hello';'Howdy']
This generated a 2 × 5 matrix of characters.
With the character matrix, we can refer to an individual element, that is a character, or a separated row, that is one of the strings:
As rows within a matrix should always be of similar length, the shorter strings should be padded with blanks so that all the strings have similar length, or else an error will occur.
>> greetmat = ['Hello'; 'Goodbye']
??? Error using ==> vertcat
The dimensions of CAT arguments are not consistent.
>> greetmat = ['Hello '; 'Goodbye']