|
You can try this as well!!!
%# get input XLS files
dName = uigetdir('.', 'Select folder containing Excel XLS files');
if dName==0, error('No folder selected'); end
files = dir( fullfile(dName,'*.xls') );
files = strcat(dName, filesep, {files.name}'); %'
%# prepare output XLS file
[fName dName] = uiputfile({'*.xls' 'Excel (*.xls)'}, 'Output File', 'final.xls');
if dName==0, error('No file selected'); end
fOut = fullfile(dName,fName);
%# process
NUM_SHEETS = 5; %# number of sheets per file
for s=1:NUM_SHEETS
%# extract contents of same sheet from all files
numData = cell(numel(files),1);
for f=1:numel(files)
numData{f} = xlsread(files{f}, s);
end
%# rearrange data
numData = cat(3,numData{:});
numData = reshape(permute(numData,[3 1 2]), [], size(numData,2));
%# write data to corresponding sheet of output XLS file
xlswrite(fOut, numData, s);
end
"Ryan" wrote in message <k71ft0$og2$1@newscl01ah.mathworks.com>...
> Read All Files in a Folder:
>
> Data Import and Export:
> http://www.mathworks.com/help/pdf_doc/matlab/import_export.pdf
>
>
> What is MATLAB?:
> http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
>
>
>
> "Johan" wrote in message <k6op5k$fhj$1@newscl01ah.mathworks.com>...
> > "Steven_Lord" <slord@mathworks.com> wrote in message <k6ooc8$c75$1@newscl01ah.mathworks.com>...
> > >
> > >
> > > "Johan " <etk50505@stud.uni-stuttgart.de> wrote in message
> > > news:k6om7t$30b$1@newscl01ah.mathworks.com...
> > >
> > > *snip*
> > >
> > > > I tried something similar before, until I found this thread an hoped to
> > > > get a solution for my problem. But it still doesn't work for me.
> > > > When I tell matlab to search all files with endings .xlsx, I get a matrix
> > > > with all information about my excel file, including their filenames. As
> > > > you explained, I decalare a variable called FileToLoad, with the name of
> > > > my excelfile.
> > > > When I then try to use xlsread('FileToLoad') it doesnt work cause matlab
> > > > can't find a file called FileToLoad.
> > >
> > > That's correct. xlsread('FileToLoad') attempts to read in a file with the
> > > name FileToLoad and a "supported Excel extension." xlsread(FileToLoad)
> > > attempts to read in the file whose name is stored in the variable
> > > FileToLoad.
> > >
> > > > Thats right so far, but why doesnt matlab simply use the information from
> > > > the variable 'FileToLoad' instead... for example (mydata.xlsx).
> > >
> > > Because MATLAB does what you tell it to do. We try to limit the
> > > circumstances under which MATLAB does what it _thinks you meant_ instead of
> > > what you _told it to do_ because it's easy to get the "mind reading" part of
> > > that wrong. [Maybe once the Mind Reading Toolbox is operational ...]
> > >
> > > --
> > > Steve Lord
> > > slord@mathworks.com
> > > To contact Technical Support use the Contact Us link on
> > > http://www.mathworks.com
> >
> > Thank you guys!
> >
> > I could swear, I tried this before...
> > Really stupid of me, when i really forget to try the simplest solution.
|