Removing the suffix from a variable name

조회 수: 12 (최근 30일)
L'O.G.
L'O.G. 2022년 7월 19일
댓글: Stephen23 2022년 7월 19일
I have many variables all called something like A_YYY where YYY can be any combination of characters and numbers of different length. How do I automatically rename all of the variables as simply A to analyze in a loop?
  댓글 수: 1
Stephen23
Stephen23 2022년 7월 19일
"How do I automatically rename all of the variables as simply A to analyze in a loop?"
By not creating them as separate variables:
I doubt that you wrote out all of those variable names by hand, which means you forgot to tell us the most important information: how did you get all of those variables into the workspace? That would be the best palce to fix this bad data design. For example, if they are loaded from a file then you should LOAD them into an output varaible:
S = load(...)

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

답변 (1개)

Image Analyst
Image Analyst 2022년 7월 19일
It's best to avoid that situation in the first place and make them as elements of an array when they're "created". See the FAQ:

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by