I have to solve a system equation in my matlab code.
At first, I try to solve it by using symbolic calculus by defining the unknown variables as
syms x1 x2 x3 'real'
and by using the function solve
[sx1 sx2 sx3] = solve(f1 == 0, f2 == 0, f3 == 0);
where f1, f2, f3
are function of x1, x2, x3
.
I know that sometimes the solution can be found, but there are cases for which solutions do not exist and I get
Warning: Explicit solution could not be found.
In this case I would like to somehow "catch" this warning (without print nothing on the screen!) and run other code.
How can achieve this?
Thanks in advance
try, catch
block around the solve operation? – Myles Bakerwarning on backtrace
, which prints the stack trace upon the exception. You can determine the level where the error is thrown and intercept it. Outside of that, you may just need to suppress the warnings. – Myles Baker