How can I combine multiple cell arrays and double arrays into a specific format that I need?

조회 수: 2 (최근 30일)
Hi, this might be a very simple problem but I am stuck.
I have two 5x1 cell arrays and one 5x1 double array. I need to combine them into a 5x3 cell array. Somehow I am getting stuck into converting the data into the format that I need. Let me explain using an example:
vStrNames1 = {'a';'b';'c';'d';'e'}
vStrNames2 = {'v';'w';'x';'y';'z'}
vDblNumbers = [1;2;3;4;5]
When I try to combine these by using:
test = {vStrNames, vStrNames2, vDblNumbers}
I get the following result:
test =
{5x1 cell} {5x1 cell} [5x1 double]
But ultimately I need to create the following:
test =
'a' 'v' [1]
'b' 'w' [2]
'c' 'x' [3]
'd' 'y' [4]
'e' 'z' [5]
How can I achieve this? Thanks for any hint Sven

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2014년 7월 24일
vStrNames1 = {'a';'b';'c';'d';'e'}
vStrNames2 = {'v';'w';'x';'y';'z'}
vDblNumbers = [1;2;3;4;5]
test = [vStrNames1,vStrNames2, num2cell(vDblNumbers)]

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by