How to summon a double variable that it's name was stored in a string?
Show older comments
during my program I want to summon a double variable that it's name saved in a string before!How can do it?
Accepted Answer
More Answers (1)
Daniel Shub
on 19 Oct 2011
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.
1 Comment
Pouya Jamali
on 19 Oct 2011
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!