I want to concate two tables vertically.the table has no variable name.how can I do that?

조회 수: 6 (최근 30일)
size of one table is 2*4(contains number) and another is 1*4(contains single charcter),bt ineed a table of 3*4 combining these two table.how?
  댓글 수: 3
KL
KL 2017년 11월 28일
Take a minute and describe your problem. Your description is nowhere close to your post's title.

댓글을 달려면 로그인하십시오.

채택된 답변

Birdman
Birdman 2017년 11월 28일
편집: Birdman 2017년 11월 28일
x=[1 2 3 4;6 7 3 4];
y=['A' 'B' 'C' 'D'];
x=reshape(char(string(x(:))),2,4);
Table=array2table([x;y])

추가 답변 (2개)

Jan
Jan 2017년 11월 28일
T1 = array2table([1,2,3,4; 5,6,7,8]);
T2 = array2table('ABCD')
C12 = [table2cell(T1); table2cell(T2)];
T12 = array2table(C12)
Mh, I'm not convinced. There should be a way without a conversion to a cell. But:
T12 = [T1; T2]
sets the values of the numbers to empty matrices.
  댓글 수: 2
Nixon Dhar
Nixon Dhar 2017년 11월 28일
편집: Nixon Dhar 2017년 11월 28일
it works well,real.size s 4356*400,bt when I want to see the table,it taking too much time,why??
Jan
Jan 2017년 11월 28일
What exactly is "too much"? You can use the profiler to find out, where the time is spent.

댓글을 달려면 로그인하십시오.


Peter Perkins
Peter Perkins 2017년 11월 29일
The problem here is that the requirement of two rows that are numbers and one row that is text is exactly the opposite orientation that tables are designed for. So Jan's solution creates what is essentially one 3x4 cell array, with numbers in some cells and text in others, while cvklpstunc's solution turns the numbers into text.
I'm guessing that this is all about display, not about creating a table for manipulating data. If you were storing those data, you'd want to do it like this:
>> x = [1 2 3 4;6 7 3 4];
>> y = ['A' 'B' 'C' 'D'];
>> t = table(x(1,:)', x(2,:)', y')
t =
4×3 table
Var1 Var2 Var3
____ ____ ____
1 6 A
2 7 B
3 3 C
4 4 D
Jan's solution ends up displaying something like
T12 =
3×4 table
C121 C122 C123 C124
____ ____ ____ ____
[1] [2] [3] [4]
[5] [6] [7] [8]
'A' 'B' 'C' 'D'
which probably is not desirable for display.

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by