How to import multiple .xlsx files all within the current directory in an organizational manner?

I have tried many ways of importing multiple .xlsx files from my current directory but have been unable to import it so it can be used for data analysis. So my question is: Is it possible to be able to import multiple .xslx files (my files are only 1 column of data each) into Matlab in such a way that I could recall each file separately under a handle or a matrix so I can more quickly perform data analysis without having to continuously import data for each and then analyze? Any help would GREATLY be appreciated!

 Accepted Answer

I don't understand what's your problem. Your approach for importing multiple files is correct.
You cannot have a "handle" to a file but you can store your imported data into a sructure (inside the loop):
data.(['a' num2str(k)]) = xlsread(allfiles{k})
Then in the analyses you can refer to data.a for a specific file.

More Answers (1)

This is one method I have tried. It has successfully organized it. But I can't seem to actually select one particular file or any for that matter to perform the data analysis. allfiles = dir('*.xlsx'); numfiles = length(allfiles); mydata = cell(1, numfiles); for k = 1:numfiles mydata{k} = xlsread(allfiles(k).name); end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!