How do I access sub-columns in table
이전 댓글 표시
I have a table which conisists of two variables with three columns each.
How do I access specific columns of this table (e.g. variable "I" column with 111 and variable "J" column with 555)
I want to keep a table with "I" and "J" as headings.
>> I= [1 2 3; 1 2 3;1 2 3];
>> J= [4 5 6;4 5 6;4 5 6];
>> K=table(I,J)
K = 3×2 table
I J
___________ ___________
1 2 3 4 5 6
1 2 3 4 5 6
1 2 3 4 5 6

답변 (1개)
Try this —
I = [1 2 3; 1 2 3;1 2 3];
J = [4 5 6;4 5 6;4 5 6];
K = table(I,J)
VN = K.Properties.VariableNames;
I1 = table(K.I(:,1), 'VariableNames',{VN{1}})
J2 = table(K.J(:,2), 'VariableNames',{VN{2}})
The variable names for the variables do not automatically extract as they would for indexing such as ‘K(:,1)’ (and parentheses indexing must always be last) so to keep them it is necessary to create new table arrays.
.
카테고리
도움말 센터 및 File Exchange에서 Color and Styling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!