How do we declare multiple variables at once using letters and values of two columns of a table?

2 visualizaciones (últimos 30 días)
INTRODUCTION: Hi, I have an alpha-numeric text file. The first column contains the alpha and the second column the numeric content. An example is given below:
% test=
% a 2
% b 30
% c 45
% d 13
% e 50
I import the file as follow
fid =fopen('C:\Users\EMERSON\Desktop\test.txt');
A=textscan(fid,'%s %f');
fclose(fid);
A1=A{1,1};
A2=A{1,2};
GOAL:
i) I want to write a command that create variables using the alpha characters of the first column and the corresponding value of the second column. In this way, I would type a and enter and would obtain the result 2, or type d to obtain the result 13, and so on.
ii) Conversely, later I import an array only with numeric values I would like to substitute the values by the letters assigned above.
I wounder if someone could suggest me a command to do these things
Thanks in advance for you help
Emerson

Respuesta aceptada

Walter Roberson
Walter Roberson el 22 de Nov. de 2012

Más respuestas (0)

Categorías

Más información sobre Data Import and Export en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by