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

3 views (last 30 days)
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

Answers (1)

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

Categories

Find more on Data Types in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!