Using "If Warning" as a conditional statement
Show older comments
Hi!
Short Question: I would like my code to perform in a certain way if a warning is issued, no matter the warning. Something like
dbstop if warning
however I do not want it to stop but to break the loop or do other things. Is there a function which I can use in an "if" statement? The only possibility I found was the try - catch blcok but as far as I got, that requires to know your error.
Details/Long Q.: I have a function that takes input and does matrix inversion on many matrices. Sometimes the input is bad (it is randomly generated) and the determinant is say 0, NaN, -Inf, etc. Matlab gives me a warning for that and I want it, as soon as it sees its own warning, to stop executing the funciton and return, so that it can draw again. I used conditional statements at first (if isnan(det(A)) return; end for example), but I have many matrices and the combinations are too many to do it manually. What would be a nice way to do it?
1 Comment
Pankaj
on 30 Jan 2016
For the accepted answer kindly see the link to clear LASTWARN http://www.mathworks.com/matlabcentral/answers/39993-how-to-clear-last-warning
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!