Reputation: 926
I am newer in MATLAB. I have a code like this
results=a(1,1)+','+a(1,2);
a
is an array of words. I just want to concatenate the first two words in my array.
After running I get this error:
Undefined function or method 'plus' for input arguments of type 'cell'
Upvotes: 0
Views: 554
Reputation: 30579
How about strjoin
:
strjoin(a(1,1:2).')
Generally, it takes a row cell array. If you have a column, the transpose is necessary. A basic example,
>> c = {'banana';'orange'}
>> strjoin(c(:)',',')
ans =
banana,orange
Upvotes: 1
Reputation: 2652
Your error suggests that a
is a cell array, which means you use curly brackets ({}
) to access the data inside it. You can concatenate like this:
results = [a{1,1} a{1,2}];
Upvotes: 1