Finding location where Matlab warning was triggered

Viewed 39

I have a large codebase in Matlab (2021a Update 5, running on Mac) which triggers the warning:

Warning: Integer operands are required for colon operator when used as index.

But there is no information about where this warning is triggered. How can I find out what file and line-number it came from? So I can adress the problem.

1 Answers

Cris Luengo provided an excellent solution in a comment, so I thought I might repeat it and flag the question as answered.

To break the execution at the first line that's triggering a warning, run the following command in the Command Window beforehand.

dbstop if warning

From what I can tell, the following command resets this option.

dbclear all

Related