Concatenate variable value and variable name into new variable name.
Mostrar comentarios más antiguos
I would like to have the name of a variable into another variable name.
So if for example I define
animal = 'cat' and make some calculation: eg. mean. I would like a variable name which concatenates these two: 'cat_mean'.
So if swap to animal = 'dog' there will be created another variable named 'dog_mean'
Best regards Jesper
Respuesta aceptada
Más respuestas (2)
Orion
el 5 de Abr. de 2016
Hi,
something like :
animal = 'cat';
operation = 'mean';
result = horzcat(animal,'_',operation)
Azzi Abdelmalek
el 5 de Abr. de 2016
Editada: Azzi Abdelmalek
el 5 de Abr. de 2016
animal = 'cat'
out=sprintf('%s_mean',animal)
Categorías
Más información sobre Animation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!