String to variable name MATLAB

Solution 1:

Use eval():

var = eval(strcat('x','a'));

It will "evaluate" the string 'xa' and translate it to the value of the variable xa.

Source : MATLAB documentation