Hi can any one help me in dealing with strings in MATLAB. For example, the string
A = \'A good looking boy\'
how can we store these individual
The most intuitive way would be using strsplit
C = strsplit(A,' ')
However as it is not available in my version I suppose this is only a builtin function in matlab 2013a and above. You can find the documentation here.
If you are using an older version of matlab, you can also choose to get this File Exchange solution, which basically does the same.
As found here, you could use
>> A = 'A good looking boy';
>> C = regexp(A,'[A-z]*', 'match')
C =
'A' 'good' 'looking' 'boy'
so that
>> C{1}
ans =
A
>> C{4}
ans =
boy
>> [C{:}]
ans =
Agoodlookingboy
You can use the simple function textscan
for that:
C = textscan(A,'%s');
C will be a cell array. This function is in Matlab at least since R14.