I need to run a C++ executable from a for
loop in MATLAB. I have written the following piece of code for the purpose,
EqNumbers = [17 18 20 21 22 23];
for i = 1:length(EqNumbers)
EqNumber = EqNumbers(i);
WriteRunE_File(EqNumber);
filename=['RunE_1.tcl'];
system(['OpenSees.exe<',filename]);
end
It is working fine most of the time, however, sometimes debug errors (like the one shown below) will appear. It is prompting me for action, if I press the "Abort" button then the program will continue for the next iteration. I just want to make this process automated, every time manually pressing the abort button is not possible for me, because there are more than 1000 iteartions in the program.
I tried using try-catch end
as follows, but it did not serve the purpose.
EqNumbers = [17 18 20 21 22 23];
for i = 1:length(EqNumbers)
try
% Code to be executed goes here.
EqNumber = EqNumbers(i);
WriteRunE_File(EqNumber);
filename=['RunE_1.tcl'];
system(['OpenSees.exe<',filename]);
catch
disp('An error occurred in Equke');
disp('Execution will continue.');
end
end
I am searching for a way to bypass the error message or automatically press the "Abort" button. So that the program will move to the next iteration automatically.
Note:
I don't have access to the C++ source code (all I have is an executable), hence I cannot update the value of citaR
. That's why I am looking for a workaround in MATLAB.