I want to run the code below, inside every folder i have an excel file (data.xls) and i want to compare 10 excel files into 1. Can anyone help me? path = 'D:'; S = dir(fullfile(path, '*', 'data.xls')) for k = 1:numel(S) F = fullfile(S(k).folder,S(k).name); data = readtable(F); d = datetime(strcat(table2array((data(:,1))), {' '}, table2array((data(:,2 ))))); acceleration = table2array((data(:,3 ))); xlswrite('file.xls', data) end
Kshitij Singh answered .
2025-11-20
path = 'D:\2019';
S = dir(fullfile(path, '*', 'data.xls'))
for k = 1:numel(S)
F = fullfile(S(k).folder,S(k).name);
data = readtable(F);
d = strcat(table2array((data(:,1))), {' '}, table2array((data(:,2 ))));
out = [d data(:,3)]; % date / time / acceleration
out = renamevars(out,'Var1','Date & Time');
writetable(out,'file.xls',"Sheet",k)
end