If you have an error in your code the default functionality of MATLAB is to stop, however if you configure Debug / "stop if errors \ warnings" to always stop if error (dbstop if error) the file with error will be opened in debug mode in case of error.