0

I have a matrix m (16x3 double) and a cell array c (16x13 cell). I want to create a cell array S 16x16, so with the same number of rows, but appending the columns of c to the columns of m.

I tried:

S= {m,c};

but the results is S{1,1,} = 16x3 double, and S{1,2} = 16x13 cell.

I also tried

S = horzcat(m,c);

but it gives me an error:

Error using horzcat
Dimensions of matrices being concatenated are not consistent.

Any hint? Thank you!

1 Answer 1

3

You have to convert your matrix to a cell first:

S=[num2cell(m),c]

The [a,b] used here is just a short way of writing horizcat(a,b)

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.