MATLAB: Read multiple xls files in a for loop

for loop

Hello! I was trying to get 3 excel files to read through a for loop and do a simple function. The dates (mm/dd/yy) read into matlab code and I'd like to spit them back out as new variables that translate them back into dates via the datestr function. I know its my coding that is the problem and I've tried manipulating it several times with no success so any suggestions would be greatly appreciated! Thanks!
source_dir = '/Users/student/Documents/MATLAB/RAWS Station Data';
dest_dir = '/Users/student/Documents/MATLAB/RAWS Results';
source_files = dir(fullfile(source_dir, '*.xls'));
n=length(source_files);
i=n;
for i=1:n
a= xlsread(source_files);
d = a(:,1);
ds(i) = datestr(d,2);
end

Best Answer

Please use the debugger to find out more details:
dbstop if error
Then run the program until it stops and check:
size(datestr(d, 2))
size(ds)
Do the number of elements match?