Creating Customized strings:
There are many built-in functions which create customized strings, including blanks, char, and sprintf.
We know that the char function can be used to convert from an ASCII code to character, as the illustration shows:
>> char(97)
ans =
a
A char function can also be used to generate a matrix of characters. Whenever using the char function to generate a matrix, it will automatically pad the strings within the rows with blanks as essential so that they are all of similar length, just like the strvcat.
>> clear greetmat
>> greetmat = char('Hello','Goodbye')
greetmat =
Hello
Goodbye
>> size(greetmat)
ans =
2 7