Giving names to different files automatically

조회 수: 6 (최근 30일)
George
George 2014년 7월 8일
답변: Jos (10584) 2014년 7월 8일
Hi sorry for the "silly " question , but i have a pretty large script written and i am trying to make a bit more functional i have several hundreds variables that repeat themselves into multiple files so i would like to use the command style fname = 'name_given' and then have something like these throughout the file but with fname as first component and A, B, C ,D etc as the secondary naming components.
fname = 'new'
fname+A = VarName ===> fname_A (getting out something like this)
any ideas please?

답변 (2개)

Jos (10584)
Jos (10584) 2014년 7월 8일
Rethink your programming style critically. The basic idea about variables is that their contents change during execution of the code, and not their names…
  댓글 수: 1
George
George 2014년 7월 8일
my contents do not change, they are the same quantities over multiple files this it would be much easier to automate the naming process since the other stay the same

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


Jos (10584)
Jos (10584) 2014년 7월 8일
Maybe you can use structures?
MyStructure.A = 8 ;
MyStructure.B = 1:5 ;
MyField = 'A'
result = 2 * MyStructure.(MyField)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by