How to define the number of the column in which a variable corresponds
1 回表示 (過去 30 日間)
古いコメントを表示
I have a question about a code. I use the following command in order to read a file:
T=readtable('file.txt')
A=(T:,1);
B=(T:,2);
C=(T:,3);
which command should I use in order to define the number of the column in which a variable corresponds?
for example A coresponts to column 1 (so I want answer=1), B coresponts to column 1 (so I want answer=2), , etc.
Could you please help me?
3 件のコメント
Image Analyst
2023 年 1 月 23 日
I did help you. Below in the official Answers section. Did you even see it?
回答 (1 件)
Image Analyst
2023 年 1 月 23 日
As soon as you assign A, B, and C, you can also create a dictionary so that later in your code you can recall what column they came from
T = randi(9, 5, 3);
A = T(:, 1);
B = T(:, 2);
C = T(:, 3);
dict = dictionary(["A"; "B"; "C"], [1;2;3])
% What column is A from
col = dict("A")
% What column is B from
col = dict("B")
% What column is C from
col = dict("C")
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!