Matlab: getting "Bad error state flag" Reset to correct state "

I have a matlab script, each one now and they are outputting a message:

Caught std::exception Exception message is:
bad allocation
Unexpected error status flag encountered.  Resetting to proper state.

      

What could be causing this?

+2


a source to share


3 answers


It is a bug in MATLAB where some part of MATLAB does not handle the std :: bad_alloc exception correctly (std :: bad_alloc is an out-of-memory exception excluded from the C ++ runtime library).



Failure "Unexpected error state flag. Reset to correct state". is an internal diagnostic - you shouldn't see it until MATLAB gets into a bad state, which in this case happens because it encounters bad_alloc somewhere where it wasn't expected. Recent versions of MATLAB fix most of these problems, except in extremely low memory situations (for example, there is less than 1 kilobyte of free memory left). Which version are you using?

+2


a source


My best guess is that your script is trying to allocate some memory and crash. This error will depend on the availability of memory on your computer when you try to allocate time. The available memory will differ depending on what is happening at that time in other programs, the operating system, even in the state of your Matlab session.



For a more accurate diagnosis, you will need to tell us more, maybe even post your script.

+2


a source


This happened to me, and it turned out that I had too many files open. fclose('all')

set everything back to normal and I made sure I fopen

followed all mine fclose

.

+2


a source







All Articles