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.
MATLAB is not popping up this dialog. Your system is.
Someone created a program that uses an uninitialised variable and has undefined behaviour. They built it in debug mode. This combination results in an assertion. You cannot just turn that off.
Even if you could, you are aborting the program. That doesn't mean "ignore the problem": it means "abort the program". It's not completing its work. It's crashed. Every single time.
The executable is faulty. Period.
The author of the program should give you a release version: ideally, a non-buggy one.
Or, since the program is open source and can be found right here, you could try building a fresh version, or debugging it and contributing a fix.