MATLAB Answers

how to run multiple xlsx files once

2 views (last 30 days)
Mike on 31 Oct 2019
Commented: galaxy on 1 Nov 2019
I have a code which use one xlsx file from source folder, analyzes it and creates file into destination folder.
I would like to use this code as it is, but use multiple xlsx files at once at the source folder, and creates all new files at once into the destination folder.

  1 Comment

Alex Mcaulley
Alex Mcaulley on 31 Oct 2019
Without more details, you will need a loop to call the function for each file

Sign in to comment.

Answers (1)

galaxy on 31 Oct 2019
You can use following steps:
% select path
work_path = uigetdir('pwd', 'Select folder');
% find all xlsx files in folder
% findfiles function can get in:
work_files = findfiles('*.xlsx', work_path);
num_file = length(work_files);
for cnt_file=1:num_file
%% analysis as your code
% when want to get name of current excel file, use work_files(cnt_file), convert from cell to string if need


Mike on 31 Oct 2019
thank you,
but I have a problem with "findfiles", it is an 'Undefined function or variable'.
do you know maybe why?
galaxy on 1 Nov 2019
You can copy findfiles function to your source code.
--> It will be OK

Sign in to comment.

Sign in to answer this question.

Translated by