How can I separate the arrays when making a table?

I need to make table from two arrays.
One array is matrix of n*1 and the other array is n*5. When I make table the table size is n*2 and I want to be n*6.
Any thouhgt?
I use this command:
table=table(ttestnames,ttest_result_p);

 Accepted Answer

Try this:
n = 5;
A = rand(n,1);
B = rand(n,5);
T = array2table([A, B])
That should do what you want.

4 Comments

Because ttestnames is string and ttest_result_p is numerical, doing array2table([A, B]) would make the whole table string. I tried that and the whole table became string.
That is new information. It was not in your original Question.
Try this:
n = 5;
ttestnames = {'A';'B';'C';'D';'E'};
ttest_result_p = rand(n,5);
T1 = table(ttestnames);
T2 = array2table(ttest_result_p);
T3 = [T1, T2];
As always, my pleasure!
I looked at your other Question and left a Comment.

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

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

Start Hunting!