how to add anew column to the table using MATLAB

조회 수: 1 (최근 30일)
C PRASAD
C PRASAD 2022년 3월 17일
답변: Stephen23 2022년 3월 17일
I have Fatures data of 30*5 of size.I would like to add a column to the table as "class" and In that class every 10 rows has to named differently.First 10 rows as "Helathy' then 11 to 20 as "Myopathy" and 21 to 30 as "Neuropathy".
X=randi(10,30,5);
X=arry2table(X,'variableNames',{'feat1','feat2',feat3',feat4','feat5'};
Now I need to add a column to the table (values as taken as example) so the resultatnt must be

채택된 답변

Stephen23
Stephen23 2022년 3월 17일
M = randi(10,30,5);
T = array2table(M,'variableNames',{'feat1','feat2','feat3','feat4','feat5'})
T = 30×5 table
feat1 feat2 feat3 feat4 feat5 _____ _____ _____ _____ _____ 9 9 2 1 3 6 2 10 2 3 9 2 1 3 1 9 5 4 1 3 2 1 4 6 8 8 10 7 10 3 7 10 6 7 9 5 9 8 3 7 7 7 7 6 2 8 9 3 7 4 1 1 2 7 8 2 5 5 2 3 3 2 1 8 10 5 2 4 7 7 10 4 1 2 4 8 3 9 4 8
T.Class = repelem(["Healthy";"Myopathy";"Neuropathy"],10,1)
T = 30×6 table
feat1 feat2 feat3 feat4 feat5 Class _____ _____ _____ _____ _____ __________ 9 9 2 1 3 "Healthy" 6 2 10 2 3 "Healthy" 9 2 1 3 1 "Healthy" 9 5 4 1 3 "Healthy" 2 1 4 6 8 "Healthy" 8 10 7 10 3 "Healthy" 7 10 6 7 9 "Healthy" 5 9 8 3 7 "Healthy" 7 7 7 6 2 "Healthy" 8 9 3 7 4 "Healthy" 1 1 2 7 8 "Myopathy" 2 5 5 2 3 "Myopathy" 3 2 1 8 10 "Myopathy" 5 2 4 7 7 "Myopathy" 10 4 1 2 4 "Myopathy" 8 3 9 4 8 "Myopathy"

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by