I have several .txt
files of 2 columns, that I’d like to import and use the second column for subsequent operations. My text files are name as: profileA1.txt
, profileA2.txt
, etc… and my variables corresponding to the data of the second column are named in the subsequent code are A1
, A2
, A3
, etc…
The code works but currently I have to open manually each .txt
file with the Import data wizard, change the name of the second column and click on the import the selection. I tried to write a code (see below) to automatize these steps but it doesn’t work? Anyone has any idea to fix this code?
Thanks
for k = 1:5
myfilename = sprintf('profileA%d.txt', k);
mydata = importdata(myfilename);
Aloop = ['A' num2str(k)];
A{k} = load(myfilename.data(:,2), k);
end