Matlab: getting "Bad error state flag" Reset to correct state "
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?
a source to share
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.
a source to share