how to change 3d array to 2 d array

조회 수: 1 (최근 30일)
satria dharma
satria dharma 2021년 1월 24일
답변: Stephan 2021년 1월 24일
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