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.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 6 Jun. 2018

0 Stimmen

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

1 Kommentar

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Produkte

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by