Skip to main content

11.14) try...catch Statement


  • The try...catch statement allows the user to pass control to an alternate code block if the initial code produces an error, which would have caused Matlab to stop and display an error message
  • The use of try...catch should be minimized and should not be used to mask lazily written or buggy code
  • They can make debugging difficult, as they can hide real bugs
  • They are useful if you have identified a rare, hard to rectify artefact within your dataset and allow you to code an exception statement