how to change 3d array to 2 d array

1 visualización (últimos 30 días)
satria dharma
satria dharma el 24 de En. de 2021
Respondida: Stephan el 24 de En. de 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

Respuesta aceptada

Stephan
Stephan el 24 de En. de 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

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by