1

The following line works

array ={'a','b'; 1,2};

but

num = [1,2];
array ={'a','b'; num};

doesn't.

I also tried

array ={'a','b'; mat2cell(num)};

and

array ={'a','b'; num2cell(num)};

but neither of them worked. How can I produce a 2x2 cell matrix containing a, b, 1 and 2?

1 Answer 1

2

Use concatenation:

array = [{'a','b'}; num2cell(num)]

Or extend the cell array as follows:

array = {'a','b'};
array(end+1,:) = num2cell(num);
Sign up to request clarification or add additional context in comments.

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.