String 用逗号连接两个字符串
我在MATLAB方面比较新。 我有这样的代码String 用逗号连接两个字符串,string,matlab,concatenation,string-concatenation,String,Matlab,Concatenation,String Concatenation,我在MATLAB方面比较新。 我有这样的代码 results=a(1,1)+','+a(1,2); a是一个单词数组。我只想连接数组中的前两个单词 运行后,我收到以下错误: Undefined function or method 'plus' for input arguments of type 'cell' 您的错误表明a是a,这意味着您使用大括号({})来访问其中的数据。您可以这样连接: results = [a{1,1} a{1,2}]; 那么: 通常,它采用行单元格数组。如果你
results=a(1,1)+','+a(1,2);
a
是一个单词数组。我只想连接数组中的前两个单词
运行后,我收到以下错误:
Undefined function or method 'plus' for input arguments of type 'cell'
您的错误表明
a
是a,这意味着您使用大括号({}
)来访问其中的数据。您可以这样连接:
results = [a{1,1} a{1,2}];
那么:
通常,它采用行单元格数组。如果你有一列,转置是必要的。一个基本的例子,
>> c = {'banana';'orange'}
>> strjoin(c(:)',',')
ans =
banana,orange
>> c = {'banana';'orange'}
>> strjoin(c(:)',',')
ans =
banana,orange