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

1 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2012-11-22

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Whos 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by