Filter löschen
Filter löschen

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

11 Ansichten (letzte 30 Tage)
C Smyth
C Smyth am 3 Okt. 2018
Bearbeitet: Matt J am 3 Okt. 2018
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 Kommentar
Stephen23
Stephen23 am 3 Okt. 2018
Bearbeitet: Stephen23 am 3 Okt. 2018
"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:

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 3 Okt. 2018
Bearbeitet: Matt J am 3 Okt. 2018
It is possible, but only by ignoring the advice given here and here.

Community Treasure Hunt

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

Start Hunting!

Translated by