xlsread errors happened after running correctly for 334 times

1 view (last 30 days)
Hi all,
I ran the following code:
for n=1:500
a=zeros(650,12);%clear ArenaRead
b=zeros(200,3);%clear AreanWrite
xlswrite(ArenaRead,a,SN,'B101')
xlswrite(ArenaWrite,b,'ArenaWrite1','A2')
[WO,WOListS,ArenaR]=WOGT_ATCmetaraps();
xlswrite(ArenaRead,ArenaR,SN,'B101')
%run Arena,calculate total tardiness and completion time in Arena
%winopen('c:\ArenaModel\Building K Scheduling Model_v28.doe')
Arenapps=actxserver('Arena.Application');
eModel=Arenapps.Models.Open(modelname);
eModel.Go;
eModel.End;
eModel.Save;
eModel.Close;
%write the data to an array variable
b=xlsread(filename,'BasicRule','J12:J13');
Perf(n,:)=b';%makespan and total tardiness
end
I got the following errors when n=334 :
Error registering event(s), Advise failed
Error in registerevent>addevent (line 148)
list(m+1) = handle.listener(h, eventname, {@comeventcallback, eventhandler});
Error in registerevent (line 94)
addevent(h, event, eventhandler);
Error in xlsreadCOM (line 11)
Excel.registerevent({'WorkbookActivate', @WorkbookActivateHandler});
Error in xlsread (line 230)
[numericData, textData, rawData, customOutput] = xlsreadCOM(file, sheet, range, Excel,
customFun);
Error in WOGT_ATCmetaraps (line 7)
[WO,dd]=xlsread(filename,sheet,'A2:T610');
Error in WritetoATCmeta (line 30)
[WO,WOListS,ArenaR]=WOGT_ATCmetaraps();
I do not understand why it runs correctly for 334 iterations but error happens at that time. Hope professions can help me to figure out the cause of this error. Thank you!

Answers (1)

Rodrigo Souto
Rodrigo Souto on 9 Sep 2014
  1 Comment
Vigneshwar Pesaru
Vigneshwar Pesaru on 18 Dec 2016
It is because of multiple usage and calling of xlsread and xlswrite function,so inorder to avoid this,please provide pause to give enough time for excel to clear its memory.
Thank you

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!