Matlab 把所有的床单都收集起来
我在同一个目录下有很多excel文件…每个excel文件都有几张表在里面 我可以知道如何将所有excel文件中的所有工作表收集到新的excel文件中吗Matlab 把所有的床单都收集起来,matlab,xls,Matlab,Xls,我在同一个目录下有很多excel文件…每个excel文件都有几张表在里面 我可以知道如何将所有excel文件中的所有工作表收集到新的excel文件中吗 names=dir('*.xls'); names={names.name}; output='out.xls'; for i=1:length(names) z = xlsread(names{i}); xlswrite(output,z); end 继续出错…有人能帮忙吗 以下是一种可能的实现: %# get all XLS files
names=dir('*.xls');
names={names.name};
output='out.xls';
for i=1:length(names)
z = xlsread(names{i});
xlswrite(output,z);
end
继续出错…有人能帮忙吗 以下是一种可能的实现:
%# get all XLS files in source directory
dirName = '.\in';
files = dir( fullfile(dirName,'*.xls') );
files = {files.name}'; %'
%# for each input file
for i=1:numel(files)
fname = fullfile(dirName, files{i}); %# absolute-path filename
[~,f] = fileparts(fname); %# used to name sheets in output
%# loop over each sheet in input file
[~,sheets] = xlsfinfo(fname);
for s=1:numel(sheets)
%# read content
[~,~,rawData] = xlsread(fname, sheets{s});
%# write to output file as new sheet
xlswrite('out.xls', rawData, [f '_' sheets{s}]);
end
end
以下是一个很好的开始参考:。另外,StackOverflow对在MATLAB中操作Excel文件有很多问题(搜索是你的朋友),我尝试编写代码并将其粘贴到问题中..但是保留错误..我不知道为什么..发布错误也会有帮助。