MATLAB: How to convert strings to a matrix

convertmatrix

I'm trying to convert strings to a matrix E.g Hello world would be [hello, world]
I have a .m file, and I'm able to read my strings but I don't know how to convert them. Can someone help me.

Best Answer

This code takes in account more then one blanck space
s='Hello world'
s1=regexp(s,' ','split');
out=s1(~cellfun(@isempty ,s1))