select all .xls files together and read one by one( without naming .xls file in a specified name)

1 view (last 30 days)
in a folder there are several .xls files and name of these aren't specified. it's needed by selecting 1 or 2 or 3 or ever other numbers of those, one by on has been read by MATLAB and then display this message fprint'filename.xls checked' for example:these files are in folder: a.xls, as.xls, lku.xls, fd.xls,... after reading each one, matlab show message about that, 'like:a.xls checked'
my opinion:
cd(path of the folder);
put names of all files in a matrix like r
for i=1:size(r,1)
[dfile,pathname]=uigetfile('*.xls','Select Data File');
f = xlsread(dfile(1,i))
func(f)%%func is a function that do something on f and give some outputs
fprint'filename.xls checked'
end
thanks a lot

Accepted Answer

bym
bym on 3 Sep 2011
d = dir('*.xls');
for k = 1:numel(d)
%open file & do stuff here
fprintf('%s\tchecked\n',d(k).name)
end
  3 Comments
mohammad
mohammad on 3 Sep 2011
thanks, perfect, i didn't type 't' after '\' in fprintf('%s\start\n',h(k).name)
now there is no warning
thanks a lot

Sign in to comment.

More Answers (0)

Categories

Find more on File Operations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!