How do I extract column name of table in MATLAB?

1.804 visualizaciones (últimos 30 días)
Pafi Pafian
Pafi Pafian el 5 de Feb. de 2015
Editada: MathWorks Support Team el 5 de Jun. de 2024
Can you suggest me a way to extract name of specific column of table in MATLAB?

Respuesta aceptada

Michael Haderlein
Michael Haderlein el 4 de Sept. de 2024
Editada: MathWorks Support Team el 5 de Jun. de 2024
If you refer to "table": 
LastName = ["Sanchez";"Johnson";"Li";"Diaz";"Brown"]; Age = [38;43;38;40;49]; Smoker = logical([1;0;1;0;1]); T = table(LastName,Age,Smoker); >> T.Properties.VariableNames ans = 1×3 cell array {'LastName'} {'Age'} {'Smoker'} >> T.Properties.VariableNames{2} ans = 'Age'
If you refer to "uitable":
f = figure("Position",[200 200 400 150]); dat = rand(3); cnames = ["X-Data","Y-Data","Z-Data"]; rnames = ["First","Second","Third"]; t = uitable("Parent",f, "Data",dat, "ColumnName",cnames,... "RowName",rnames, "Position",[20 20 360 100]); >> get(t,"columnname") ans = 3×1 cell array {'X-Data'} {'Y-Data'} {'Z-Data'}
  4 comentarios
Alex Whiteway
Alex Whiteway el 20 de Mayo de 2021
Editada: Alex Whiteway el 20 de Mayo de 2021
>> T.Properties.VariableNames{2}
ans =
'Age'
PRABAKARAN KANDASAMY
PRABAKARAN KANDASAMY el 21 de Mzo. de 2024
nice answer

Iniciar sesión para comentar.

Más respuestas (1)

Vencel Kozma
Vencel Kozma el 2 de Dic. de 2022
You could also use only these 2 lines:
excel_struct = table2struct(excel_table);
SelectedColumn_var = extractfield(excel_struct, 'SelectedColumn')';

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by