Change variable names in a table

Hi all,
I would like to change all variable names within a table, to attached file, a cell array.
This is what i use now;
rf1.Properties.VariableNames = vars1

 Respuesta aceptada

Stephen23
Stephen23 el 22 de Nov. de 2018
Editada: Stephen23 el 22 de Nov. de 2018

3 votos

You can use a cell array of names, like this:
rfi.Properties.VariableNames = {'name1','name2',...}

5 comentarios

Jesse
Jesse el 22 de Nov. de 2018
In this way i have to set the names manually. The names i want to assign are from another table...
Guillaume
Guillaume el 22 de Nov. de 2018
What is the problem?
rfi.Properties.VariableNames = yourothertable.Properties.VariableNames
as long as both tables have the same number of variables obviously. If not, you'd have to add/remove elements to the cell array returned by yourothertable.Properties.VariableNames.
Stephen23
Stephen23 el 22 de Nov. de 2018
"In this way i have to set the names manually"
Nope. The names must be in a cell array or a string array, and while you could define that array manually, it is certainly not required. Why not just get the names of the other table using this:
C = othertable.Properties.VariableNames
rfi.Properties.VariableNames = C
Sampath Rachumallu
Sampath Rachumallu el 29 de Jun. de 2020
Unable to add spaces in Column names of a table using above.
Steven Lord
Steven Lord el 29 de Jun. de 2020
The ability to have spaces in table variable names was introduced in release R2019b as stated in the Release Notes.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2018a

Preguntada:

el 22 de Nov. de 2018

Comentada:

el 27 de Jul. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by