Effacer les filtres
Effacer les filtres

How can I combine text and numbers to a new variable?

9 vues (au cours des 30 derniers jours)
Robert Berghaus
Robert Berghaus le 25 Juil 2017
Modifié(e) : the cyclist le 25 Juil 2017
I need to combine a written part with a number I define before, to implement many new variables. For example
number=42
(['hallo',number])=anyvalue
What I want to get is
hallo42=anyvalue %or
hallo42=17
(1x1double) it is called I think. Thank you.

Réponse acceptée

the cyclist
the cyclist le 25 Juil 2017
Modifié(e) : the cyclist le 25 Juil 2017
You should use a cell array.
number=42
hallo{number} = 17;
You might think it is better to have a series of variables with names like
hallo42
hallo43
etc ...
But you will find many, many threads on this forum explaining why that is a bad programming practice.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion 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