Adding a string in front of every variable in a table

조회 수: 4 (최근 30일)
BA
BA 2022년 9월 20일
댓글: Eric Sofen 2022년 9월 21일
I was looking to make a script that added a string in front of every variable in my table.
For example, I want to add "Table_" in front of every variable in the table I've attached to this post.

채택된 답변

Voss
Voss 2022년 9월 20일
% read the table
t = readtable('Ztable.xlsx','VariableNamingRule','preserve');
% modify the variable names
t.Properties.VariableNames = strcat('Table_',t.Properties.VariableNames);
% save the table
writetable(t,'Ztable_modified.xlsx')
  댓글 수: 2
BA
BA 2022년 9월 20일
Thank you!
Eric Sofen
Eric Sofen 2022년 9월 21일
Or using the string data type...
t.Properties.VariableNames = "Table_" + t.Properties.VariableNames;

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by