MATLAB suddenly closes when running a complex script
57 views (last 30 days)
Jan on 9 Apr 2021
Without seeing the code it is impossible to suggest a solution. There is no magic "do not crash"-flag, which can be enabled by professionals only.
You have to debug the code. Set some breakpoints to step through the code line by line. If this is too lengthy, try to enable the diary and display all performed commands:
% now run the code again
After Matlab has crashed again, check the event log of the operating system also for a new entry.
If you have found out, where the code crashs, insert some code to stop the execution exactly before the crash, e.g.:
if k==17 && b==47196
keyboard; % -> Breakpoint here
Then save the variables provided as input for the next step in a MAT file, such that you can examine the reason without the need for the former processing. The next command together with the input data are a useful start point to explain the details here in the forum.