import multiple spreadsheats at once (.xlsx files)
Mostra commenti meno recenti
so I have to import multiple spreadsheats at once (roughly 400). I can import them all manually like
filename='20150901_1.xlsx'
A1=xlsread(filename);
filename2='20150902_1.xlsx'
A2=xlsread(filename2)
Is there a faster way to do this? The spreadsheats are all 2D matrices. thanks in advance
Risposte (1)
Joseph Cheng
il 13 Mag 2017
Modificato: Joseph Cheng
il 13 Mag 2017
well first you'll want to get away from generating variables in that fashion as you'll basically have A400 or more which is hard to keep track of. instead of manually you can use the function dir() which can poll a file for the files in a folder. (in combination with uigetdir/uigetfile you can navigate to another folder without coding in the file locations.)
example:
xlfiles = dir('*.xlsx')
for ind = 1:numel(xlfiles)
A(:,:,ind) = xlsread(xlfiles(ind).name);
end
if they are at different sizes you can use structs which i think goes like this:
data = struct('A',[])
for ind = 1:numel(xlfiles)
data(ind).A = xlsread(xlfiles(ind).name);
end
or alternatively put it into a cell array
1 Commento
Joey Smit
il 13 Mag 2017
Categorie
Scopri di più su Structures in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!