Rename all variables in table

Suppose I have a table T about New York with variables a,b,c.... I would like to rename all variables in T as 'NYa",'NYb',.... etc without renaming variables one by one. Please advise.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 6 de Jun. de 2018

0 votos

T.Properties.VariableNames = cellfun(@(S) ['NY', S], T.Properties.VariableNames', 'Uniform', 0);

1 comentario

Peter Perkins
Peter Perkins el 8 de Jun. de 2018
insertBefore({'a' 'b'},1,'NY') (or strcat('NY',t.Properties.VariableNames) before R2016b-ish, I forget exactly when) would also do the trick.

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Etiquetas

Preguntada:

el 6 de Jun. de 2018

Comentada:

el 8 de Jun. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by