I'm trying to import multiple datafiles, called 1min1, 1min2, 1min3, 1min4 etc. They'll undergo some processing (subtraction of certain columns, multiplication of some values, etc) and the end result per file is one column. I want matlab to save each of these columns in a variable that is equal to the file name. So, in go multiple files 1min1, 1min2, 1min3, 1min4 etc, out come several variables with the same name, but just one column/variable.
I try to use this:
i=20; %nr of files
name='1min'; %basic filename
norm=8; %normalisation factor
for k=1:i
fileName = strcat(name,num2str(k));
A= load(fileName);
[thisshouldbethesamefilename]=(A(:,7)-A(:,6))/A(1,12)*norm;
end
In the end I want to make this a function where I only input the filename, the nr of files and the normalisation factor, and it gives me the resulting columns as separate variables. I know I could put all columns in the same file (e.g. using B(:,1), B(:,2) etc) but I want to see the original filename so I know where the data originated. I've tried a couple of things with genvarname, eval and similar things, but haven't succeeded. Probably something simple, help is appreciated!
eval, but why do you want to? Use a cell array instead, and store the file names for reference. Possibly usecontainers.Mapclass if you want to get fancy, and allow lookups based on file name.