solve() behaving unexpectedly with multiple inequalities
3 views (last 30 days)
Show older comments
I'm encountering strange behavior with what should be straightforward calculations using solve(). I've been experimenting with this a bit to try and see if I can explain it, but I'm coming up with nothing. I'm stumped as to what's going on - the below image encapsulating a minimal working example is what made me give up and resort to asking here:
As you can see here, the ability of solve() to find a solution appears to depend on the names of the variables. Or at least, I think that's what's going on.
Below is a similar example of strange behavior demonstrating that solve() is, in fact, able to handle this when the parameters are handled in separate calls:
Am I doing something wrong here? Is MATLAB interpreting my input in an unintended fashion that is leading to this behavior?
2 Comments
Cris LaPierre
on 31 Jul 2021
It doesn't have to do with the variables used. I get the same behavior if I use a and b.
It seems to have something to do with the alphabetical order in which the variables are solved for.
syms a b
S1=solve([0>=b 0<=b a>=0],[a b])
S2=solve([0>=b 0<=b a>=0],[b a])
I know this is not an answer (hence why I'm adding it as a comment). As for why, I don't know. Perhaps some insight can be gained through this example. Note that, when it does yield a solution, it does so under conditions. Those can be viewed using the 'ReturnConditions',true input.
S3=solve([0>=b 0<=b a>=0],[b a],'ReturnConditions',true)
S3.parameters
S3.conditions
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!