0
次のループは、actxserverを使用してexcelのデータをmatlabに読み込みます。ループは、Excelからのデータが大きすぎるというエラーのために完了しません。私はこれを信じるのが難しいと思うのは、それぞれ約14000行と21列の75枚のエクセルシートがあるため、データセットは非常に大規模ではありません。したがって、問題またはデータセットを引き起こしているループが大きすぎるかどうかはわかりません。次のようにmatlab actxserver
スクリプトは次のとおりです。
clear all
%obtain the name of each of the folders under investigation
path='F:\University\CEH Lancaster\Project\Practice';
folder = path;
dirListing = dir(folder);
dirListing=dirListing(3:end);%first 2 are just pointers
for i=1:length(dirListing);
Folder_Name{i}=dirListing(i,1).name;
f{i} = fullfile(path, dirListing(i,1).name);%obtain the name of each folder
files{i}=dir(fullfile(f{i},'*.xls'));%find the .xls files
for j=1:length(files{1,i});
File_Name{1,i}{j,1}=files{1,i}(j,1).name;%find the name of each .xls file in each folder
end
end
%manually obtain the name of the required worksheets
Name_workbook={'Data1', 'Data2', 'Data3', 'Data4'};
%read data in from excel
excel = actxserver('Excel.Application');
excel.Visible=0;
for i=1:length(File_Name);
a(i)=length(File_Name{1,i});
for j=1:a(i);
file{1,i}{j,1}=excel.Workbooks.Open(fullfile(path,Folder_Name{1,i},File_Name{1,i}{j,1}));
sheet1{1,i}{j,1}=excel.Worksheets.get('Item', Name_workbook(1,i));
MyRange{1,i}{j,1}=sheet1{1,i}{j,1}.UsedRange;
MyData{1,i}{j,1}=MyRange{1,i}{j,1}.Value;
end
end
誰も私が次に試してみてください何についての意見を持っていますか?
1つの行と1つの列の1つのシートで機能しますか? – Aabaz