Hi, I have read a few topics that discussed saving new variable names in loops, however i could not find any that resolved my problem.
I am trying to import '.txt' files, a matrix with approx 16 columns. Each time i import them, i want to name each new matrix with a new name, I.e. T1, T2, T3 etc. I can do it manually, however this is time consuming and i have many files in different folders that i will wish to import.
My script follows:
fpath=uigetdir; % user selected path to directory files=dir([fpath '\*.txt']); % open directory, list files ending txt files=char(files.name); % list of file names
m=1:length(files); for i=1:length (m); % Importing data files T_1=importdata([files((1),:)]);
for x=1:length(files); %($$$$$$$$$$$$) T(x)=T_1.data; end end
I know that where the line i have marked as '($$$$$$$$)', is wrong, but i am struggling to change the name. Ideally, i would like to name the matrix with a reference to the file name, but i am not too worried about that at the moment.