To convert a string to a cell array, you can simply use the cellstr
function as follows:
main.m43 chars3 lines
This will convert the string 'string'
to a cell array {'string'}
. If the input string contains multiple words separated by spaces, each word will be stored in a separate cell:
main.m53 chars3 lines
This will result in the cell array {'this', 'is', 'a', 'string'}
.
gistlibby LogSnag