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

4 次查看(过去 30 天)
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 中查找有关 Whos 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by