how to change 3d array to 2 d array

1 Ansicht (letzte 30 Tage)
satria dharma
satria dharma am 24 Jan. 2021
Beantwortet: Stephan am 24 Jan. 2021
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

Akzeptierte Antwort

Stephan
Stephan am 24 Jan. 2021
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

Weitere Antworten (0)

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by