Take elements of double matrix into elements of cell

Hello. So I have a given matrix A with dimensions of N-by-2. This matrix is of class double.
Then I have a cell B with dimensions of N-by-2; the first column of the cell has N containers with class double within each container; the second column of the cell has N containers with class char within each container.
I am trying to find a fast way to put each element of the second column of the given matrix A into its own container in the cell B, so that the dimensions of the resultant cell are ultimately N-by-3 containers.
Thanks for any help.

Answers (1)

A = randi(8,3,2)
B = [{2;8;9},{'as';'df';'fg'}]
out = [B, num2cell(A(:,2))]

Asked:

on 27 Sep 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!