Concatenate variable value and variable name into new variable name.
显示 更早的评论
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
采纳的回答
更多回答(2 个)
Orion
2016-4-5
Hi,
something like :
animal = 'cat';
operation = 'mean';
result = horzcat(animal,'_',operation)
Azzi Abdelmalek
2016-4-5
编辑:Azzi Abdelmalek
2016-4-5
animal = 'cat'
out=sprintf('%s_mean',animal)
类别
在 帮助中心 和 File Exchange 中查找有关 Animation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!