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

6 visualizzazioni (ultimi 30 giorni)
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 Commenti
KL
KL il 28 Nov 2017
Take a minute and describe your problem. Your description is nowhere close to your post's title.

Accedi per commentare.

Risposta accettata

Birdman
Birdman il 28 Nov 2017
Modificato: Birdman il 28 Nov 2017
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])

Più risposte (2)

Jan
Jan il 28 Nov 2017
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 Commenti
Nixon Dhar
Nixon Dhar il 28 Nov 2017
Modificato: Nixon Dhar il 28 Nov 2017
it works well,real.size s 4356*400,bt when I want to see the table,it taking too much time,why??
Jan
Jan il 28 Nov 2017
What exactly is "too much"? You can use the profiler to find out, where the time is spent.

Accedi per commentare.


Peter Perkins
Peter Perkins il 29 Nov 2017
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.

Categorie

Scopri di più su Tables in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by