I want to concate two tables vertically.the table has no variable name.how can I do that?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nixon Dhar
el 28 de Nov. de 2017
Respondida: Peter Perkins
el 29 de Nov. de 2017
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 comentarios
KL
el 28 de Nov. de 2017
Take a minute and describe your problem. Your description is nowhere close to your post's title.
Respuesta aceptada
Birdman
el 28 de Nov. de 2017
Editada: Birdman
el 28 de Nov. de 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])
2 comentarios
Birdman
el 28 de Nov. de 2017
x=[1 2 3 4];
y=['A' 'B' 'C' 'D'];
x=reshape(char(string(x(:))),1,4);
Table=array2table([x;y])
Más respuestas (2)
Jan
el 28 de Nov. de 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 comentarios
Jan
el 28 de Nov. de 2017
What exactly is "too much"? You can use the profiler to find out, where the time is spent.
Peter Perkins
el 29 de Nov. de 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.
0 comentarios
Ver también
Categorías
Más información sobre Tables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!