How can I use a another variable as part of the name of a new variable?

조회 수: 4 (최근 30일)
C Smyth
C Smyth 2018년 10월 3일
편집: Matt J 2018년 10월 3일
I want to be able to change two variable names to change the naming of multiple variables. For example. Participant_Number = P1; Intensity = High; I want to be able to change Participant_Number and Intensity to change the name of a new variable. So the result would be: New_Variable would be named P1_High_NewVariable
Is this possible?
  댓글 수: 1
Stephen23
Stephen23 2018년 10월 3일
편집: Stephen23 2018년 10월 3일
"Is this possible?"
Possible, yes. Good way to write code, no.
Magically accessing variable names is one way that some beginners force themselves into writing slow, complex, buggy code that it hard to debug. Read this to know why:

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

답변 (1개)

Matt J
Matt J 2018년 10월 3일
편집: Matt J 2018년 10월 3일
It is possible, but only by ignoring the advice given here and here.

카테고리

Help CenterFile Exchange에서 Use COM Objects in MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by