String to variable name MATLAB

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

Leave a Comment