MATLAB: How to split the name in to two cells

data acquisitionData Acquisition Toolboxmachine learningstatisticsStatistics and Machine Learning Toolbox

Hi,
I have a cell matrix:
'56' 'mat find false' '89 mm' 'mat 96 kl'
I want to split:
  1. 'mat find false' –> 'mat' 'find false' (one cell to two cells)
  2. 'mat 96 kl' –>'mat' '96 kl'
desired Output:
'56' 'mat' 'find false' '89 mm' 'mat' '96 kl'
Many thanks in advance,

Best Answer

Or regexp-based: if
C = {'56', 'mat find false', '89 mm', 'mat 96 kl'} ;
then
result = regexp(C, '(mat)?\s?(.*)', 'tokens', 'once') ;
result = [result{:}] ;
result(cellfun(@isempty, result)) = [] ;
outputs:
result =
1×6 cell array
'56' 'mat' 'find false' '89 mm' 'mat' '96 kl'