String to variable name MATLAB -
if instance have variable xa=2, , construct string joining 'x' , 'a', how can make new string have value 2?
xa=2; var=strcat('x','a');
the result of var=xa, want var=2.
thank you
use eval()
:
var = eval(strcat('x','a'));
it "evaluate" string 'xa'
, translate value of variable xa
.
source : matlab documentation
Comments
Post a Comment