I am running some data processing work in MATLAB and solver uses BACKSLASH operator. Sometimes, I get warning like this:
Warning: Rank deficient, rank = 1390, tol = 1.335195e-010.
Warning: Rank deficient, rank = 1386, tol = 1.333217e-010.
I would like to catch those warnings. I am trying to convert warning to error and then catch it as described here under title “Trapping warnings”: http://undocumentedmatlab.com/blog/trapping-warnings-efficiently In the example, following string has been used to convert warning to error:
s = warning('error', 'MATLAB:DELETE:Permission');
However, I am not sure what string to use for my case. I tried using
s = warning('error', 'Warning: Rank deficient’);
But, it did not work. Any help would be appreciated.
Regards, DK
You need to specify the warning identifier, not the warning text. You can find the identifier using the two-output form of lastwarn
:
[msgstr, msgid] = lastwarn
In your case, I think the identifier you want is 'MATLAB:rankDeficientMatrix'
.