필터 지우기
필터 지우기

How a table columns are named using MATALB

조회 수: 8 (최근 30일)
C PRASAD
C PRASAD 2022년 3월 5일
댓글: Simon Chan 2022년 3월 11일
I have a fetaure table with 5*10 size.Now I woul like to name each of the Coloumns
I would like to name ecah coloumn and also again 5 coloumn need to give name with Title1 as shown below.Please help me using MATLAB
  댓글 수: 1
Stephen23
Stephen23 2022년 3월 5일
편집: Stephen23 2022년 3월 6일
Adding "headers" (i.e. column/variable names) is easy if you convert the data to a table: https://www.mathworks.com/help/matlab/ref/array2table.html
However a heirarchy of column/variable names like you show is not possible in one table :https://www.mathworks.com/matlabcentral/answers/541568-nested-tables-with-duplicate-sub-column-names
You could create nested tables, but that does complicate accessing and processing your data.

댓글을 달려면 로그인하십시오.

채택된 답변

Simon Chan
Simon Chan 2022년 3월 5일
Something like the following may be similar to what you want.
clear; clc;
combine_vector = randi(10,5,10);
Title1 = array2table(combine_vector(:,1:5),'VariableNames',compose('feature%d',1:5));
Title2 = array2table(combine_vector(:,6:10),'VariableNames',compose('Sfeature%d',1:5));
T = table(Title1,Title2)
T = 5×2 table
Title1 Title2 feature1 feature2 feature3 feature4 feature5 Sfeature1 Sfeature2 Sfeature3 Sfeature4 Sfeature5 ________________________________________________________ _____________________________________________________________ 1 9 10 6 3 5 2 9 2 4 3 10 4 8 10 4 10 10 4 4 2 6 1 8 7 4 7 5 8 5 6 2 2 8 7 2 6 8 6 2 6 6 10 2 9 2 4 8 2 8
  댓글 수: 8
Simon Chan
Simon Chan 2022년 3월 11일
There is no need to save them in different variables. Stephen's recommendation is absolutely right.
In case you would like to use data on column 1,6,11. You can directly retrieve them from the variable combine_vector as follows:
combine_vector = randi(10,28,75);
combine_vector(:,[1 6 11])
ans = 28×3
8 4 10 9 6 10 1 7 1 9 7 4 8 3 2 5 2 6 8 3 10 3 8 4 10 10 10 4 3 8

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by