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!