How can I concatenate strings in a cell array with spaces between them in MATLAB?

后端 未结 5 747
青春惊慌失措
青春惊慌失措 2020-12-15 23:34

I want to concatenate (padding with spaces) the strings in a cell array {\'a\', \'b\'} to give a single string \'a b\'. How can I do this in MATLAB

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-16 00:02

    Small improvement (?) on the answer by Alex

    strs = {'a','b','c'};  
    strs_spaces = [strs{1} sprintf(' %s', strs{2:end})];
    

提交回复
热议问题