Effacer les filtres
Effacer les filtres

xlsread from different folders

9 vues (au cours des 30 derniers jours)
ricco
ricco le 1 Déc 2011
I have 4 folders in the same directory where each folder contains ~19 .xls files. I have written the code below to obtain the name of each of the folders and the name of each .xls file within the folders.
path='E:\Practice';
folder = path;
dirListing = dir(folder);
dirListing=dirListing(3:end);%first 2 are just pointers
for i=1:length(dirListing);
f{i} = fullfile(path, dirListing(i,1).name);%obtain the name of each folder
files{i}=dir(fullfile(f{i},'*.xls'));%find the .xls files
for j=1:length(files{1,i});
File_Name{1,i}{j,1}=files{1,i}(j,1).name;%find the name of each .xls file
end
end
Now I'm trying to import the data from excel into matlab by using xlsread. What I'm struggling with is knowing how to load the data into matlab within a loop where the excel files are in different directories (different folders).
This leaves me with a 1x4 cell named File_Name where each cell refers to a different folder located under 'path', and within each cell is then the name of the spreadsheets wanting to be imported. The size of the cells vary as the number of spreadsheets in each folder varies.
Any ideas?
thanks in advance

Réponses (1)

Robert Cumming
Robert Cumming le 1 Déc 2011
this is the same problem as your previous question
Stick to one question for the problem.
  2 commentaires
ricco
ricco le 1 Déc 2011
Wow i'm sorry if I confused you with 2 questions, I admit 2 is a lot.
Robert Cumming
Robert Cumming le 1 Déc 2011
i'm not confused - the question appears to be the same as your other one.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by