MATLAB: How to import numerous excel files into MATLAB

excelexporting excel datafaq 4.12importimporting excel data

A have several excel files that I need to modify through MatLab and export into a different folder. I need help with importing and exporting an entire folder of excel files.
Thanks,
-Frank
source_dir = 'C:\Users\xuf\Desktop\Excel Saved PointScans'
dest_dir = 'C:\Users\xuf\Desktop\Test Folder'
source_files = dir(fullfile(source_dir, '*.xls'));
for i = 1:length(source_files)
data = xlsread(fullfile(source_dir,source_files(i).name));
xlswrite(fullfile(dest_dir,source_files(i).name));
end

Best Answer

You won't be able to load them all at once but you could easily use a for-loop to process them one at a time. Something like this:
source_dir = 'path/to/source/'
dest_dir = '/path/to/dest'
source_files = dir(fullfile(source_dir, '*.xls'));
for i = 1:length(source_files)
data = xlsread(fullfile(source_dir, source_files(i).name)));
#do something with data
xlswrite(fullfile(dest_dir, source_files(i).name)));
end