필터 지우기
필터 지우기

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