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.
답변 (1개)
Andrei Bobrov
2012년 9월 27일
A = randi(8,3,2)
B = [{2;8;9},{'as';'df';'fg'}]
out = [B, num2cell(A(:,2))]
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!