错误发生在最后一步,Matlab说它出现了未知错误"。
以下是我的代码。它是实现这一点:解压zip.file,读取所有解压缩的文件并在每个文件中搜索某些特定信息(Information1_ID,Information2_ID,Information3_ID,Information4_ID)。将Information4_ID与许多文件夹的名称进行比较。如果其中两个相同,请将文件移动到相应的文件夹中。
你们可以告诉我可能导致这个错误的原因吗?
% unzip the file into the folder named 'zp'
unzip('ResultLogs_10_20121012_76708.52.zip','E:\matlab\zp');
% the path of the files after unzipped
Fileinzip = dir('E:\matlab\zp\m2000\AmpDetect.server\logs');
cd('E:\matlab\zp\m2000\AmpDetect.server\logs');
Length = length(Fileinzip);
% this loop go though the unzipped files
for i = 3:Length
FilesName = Fileinzip(i).name;
% read the file and get some certain information
delimiter = '\t';
starRow = 1;
endRow = inf;
formatSpec = '%s %s %*[^\n]';
fileID = fopen(FilesName);
resultArray = textscan(fileID,formatSpec,endRow+1,'Delimiter',delimiter,'EmptyValue',-Inf,'HeaderLines',starRow-1,'ReturnOnError',false);
FAM1 = 'Plate Name';
FAM1_ID = strmatch(FAM1,resultArray{1,1});
FAM2 = 'Time Stamp AD Start';
FAM2_ID = strmatch(FAM2,resultArray{1,1});
FAM3 = 'AD Serial Num';
FAM3_ID = strmatch(FAM3,resultArray{1,1});
FAM4 = 'AD App Id';
FAM4_ID = strmatch(FAM4,resultArray{1,1});
Information = resultArray{1,2};
Information1_ID = Information(FAM1_ID);
Information2_ID = Information(FAM2_ID);
Information3_ID = Information(FAM3_ID);
Information4_ID = Information(FAM4_ID);
Folder_database = dir('E:\matlab\Database\Close Mode');
Length_folder = length(Folder_database);
% go through the folders name
for rr = 3:Length_folder
Folder_Name = Folder_database(rr).name;
% if same, rename the file and move the file into the corresponding folder
if strcmp(Information4_ID,Folder_Name)
path = 'E:\matlab\zp\m2000\AmpDetect.server\logs'
oldpath = 'E:\matlab\zp\m2000\AmpDetect.server\logs';
newpath = strcat('E:\matlab\zp\m2000\AmpDetect.server\logs','\', Folder_Name); % moved to a new path
Folder_Name = strcat(Information4_ID,'_',Information3_ID,'_',Information2_ID,'_',Information1_ID);
movefile(oldpath,newpath);
end
end
end