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

testing - Detect whether test has failed within fixture -

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

android - Create single AAR file from multiple modules using Gradle -