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
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!