If for instance I have a variable xa=2, and then I construct a string by joining \'x\' and \'a\', how can I make this new string have the value 2?
xa=2; var=
Use eval():
eval()
var = eval(strcat('x','a'));
It will "evaluate" the string 'xa' and translate it to the value of the variable xa.
'xa'
xa
Source : MATLAB documentation