Rename workspace structure with cell

조회 수: 3 (최근 30일)
Jepil
Jepil 2019년 3월 26일
편집: Stephen23 2019년 3월 27일
I have a trainedModel, and I want to rename the model automaticaly by 'for'
trainedModel = struct('test', 'test')
responseNames = {'Force1', 'Force2', 'Force3', 'Force4'}
I want to change the name of structure to 'trainedModel_Force1' using reponseNames.
  댓글 수: 2
Stephen23
Stephen23 2019년 3월 27일
편집: Stephen23 2019년 3월 27일
Dynamically defining or accessing variable names is one way that beginners force themselves into writing slow, complex, obfuscated, buggy, hard-to-debug code. Read this to know why:
Indexing is simple, neat, easy to debug, and very efficient (unlike what you are trying to do). You should use indexing into one array (numeric or cell or structure), or a table, or fieldnames of a structure, or any other simpler way to store your data.

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

답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by