how to change 3d array to 2 d array

1 次查看(过去 30 天)
i have table
A 1 N
B 1 J
C 1 N
A 2 J
B 2 N
C 2 J
I want change that table to
A B C
N 1 2 1
J 2 1 2

采纳的回答

Stephan
Stephan 2021-1-24
a = ['A'; 'B'; 'C'; 'A'; 'B'; 'C'];
b = [1; 1; 1; 2; 2; 2];
c = ['N'; 'J'; 'N'; 'J'; 'N'; 'J'];
T = table(a,b,c)
T_new = unstack(T,2,1)
results in:
T =
6×3 table
a b c
_ _ _
A 1 N
B 1 J
C 1 N
A 2 J
B 2 N
C 2 J
T_new =
2×4 table
c A B C
_ _ _ _
N 1 2 1
J 2 1 2

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by