Rename all variables in table

2 次查看(过去 30 天)
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.

采纳的回答

Walter Roberson
Walter Roberson 2018-6-6
T.Properties.VariableNames = cellfun(@(S) ['NY', S], T.Properties.VariableNames', 'Uniform', 0);
  1 个评论
Peter Perkins
Peter Perkins 2018-6-8
insertBefore({'a' 'b'},1,'NY') (or strcat('NY',t.Properties.VariableNames) before R2016b-ish, I forget exactly when) would also do the trick.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by