How can I work on a valuable name with a minus sign in it...?

20 vues (au cours des 30 derniers jours)
Dice-k
Dice-k le 20 Fév 2020
Commenté : Dice-k le 20 Fév 2020
Hello,
Could you please help me to change a valuable name with a minus sign in it?
the valuable name is something like
"data.a-b"
Thus, when I try to call the valuable in the command prompt,
matlab recognizes as the following
data.a - b (i.e., data.a minus b, instead of a single valuable.)

Réponse acceptée

M
M le 20 Fév 2020
From this documentation:
"valid variable name starts with a letter, followed by letters, digits, or underscores"
You cannot include the " - " symbol in a matlab variable name.
If you want to define a variable that corresponds to " a - b", you can call it "a_minus_b".
  3 commentaires
Dice-k
Dice-k le 20 Fév 2020
Thanks Steven,
a_b = data.('a-b');
worked!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Workspace Variables and MAT-Files dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by