How do I add these files to my loop?

I have multiple files and I only want my Excel files added to the directory.
myDir = uigetdir('path'); %gets directory
myFiles = dir(fullfile(myDir));
M(length(myFiles),s)=zeros; %gets all wav files in struct
for k = 1:length(myFiles)
baseFileName = myFiles(k).name;
fullFileName = fullfile(myDir, baseFileName);
A = readmatrix(fullFileName,'Whitespace',' []');
end

Answers (1)

Try this:
filePattern = fullfile(myDir, '*.xls*');
myFiles = dir(filePattern);

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Asked:

on 18 Jun 2020

Answered:

on 18 Jun 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!