0

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'

2 Answers 2

1

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}];
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.