How a table columns are named using MATALB
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a fetaure table with 5*10 size.Now I woul like to name each of the Coloumns
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/915164/image.jpeg)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/915169/image.jpeg)
1 commentaire
Stephen23
le 5 Mar 2022
Modifié(e) : Stephen23
le 6 Mar 2022
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.
Réponse acceptée
Simon Chan
le 5 Mar 2022
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)
8 commentaires
Simon Chan
le 11 Mar 2022
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])
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!