how to use "warning" message to control the flow of my program
1 view (last 30 days)
Show older comments
I have a linear equation Ax=b, where A is a square matrix and b is a vector. I want to use the warning message generated by command x=linsolve(A,b) that if the condition number of A is too big that the solution of x may be inaccurate to control the flow of my code. For example, if the warning message occurs, I would call a function to generate a new matrix A. My question is how to realize this in matlab.
Another question is: if I use the condition number of A to control the flow of my code, what's the limit I should set on the condition number of A to ensure the solution of x is accurate.
Thanks.
0 Comments
Answers (1)
Walter Roberson
on 16 Jan 2012
Perhaps it would be easier to calculate cond() (or perhaps rcond()) and branch on that instead of controlling the warning.
But if you prefer: before the linsolve() call,
lastwarn('')
and then after linsolve() test to see if lastwarn() is the message identifier associated with that warning.
0 Comments
See Also
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!