How to read the symbols used in a variable name

1 visualización (últimos 30 días)
Justin Callahan
Justin Callahan el 2 de Nov. de 2012
Firstly, I am not certain this is even possible. What I am trying to do is read the individual characters of the name of the variable itself. IE, I have a variable named AB and a variable named AC. I want to define another variable as "A_first"(since A is the first variable in the list) that is equal to the value and AB and AC (in an array). Does anyone know if this is possible?

Respuestas (1)

Walter Roberson
Walter Roberson el 3 de Nov. de 2012
varname = @(v) inputname(1);
AB = 321;
varname(AB) %would be 'AB'
However, what you are trying to do is seldom a good idea. See http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by