How to summon a double variable that it's name was stored in a string?
古いコメントを表示
during my program I want to summon a double variable that it's name saved in a string before!How can do it?
採用された回答
その他の回答 (1 件)
Daniel Shub
2011 年 10 月 19 日
Building on David's answer
xxx = 3;
varname = 'xxx';
val_of_xxx = eval(varname);
can be replaced with
data.xxx = 3;
varname = 'xxx';
val_of_xxx = data.(varname);
The advantage of the latter is it avoids the eval.
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!