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

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -