matlab - MuPAD: How to determine just the existence of solutions to a set of linear inequalities?

Using MuPAD, I want to find out if at least one solution exists for a set of of linear inequalities. For example, the following system of linear inequalities:

enter image description here

which I solve in MuPAD by:


and MuPAD returns the set of solutions, in some type of notation:

enter image description here

However, I do not care about the exact form of the solution set, i.e., whether it is finite, or infinite, I just care if there is at least one viable solution.

I would like to call MuPAD from Matlab, ask if a solution set exists to the inequalities, and then get back a "yes" or "no" answer. I could test for the empty set being returned, but I do not know how to test if a symbolic variable represents the empty set.

1 Answer

  1. Alan- Reply


    Here's an example using MuPAD's solve and sym/isempty called from Matlab:

    syms x y z;
    ~isempty(feval(symengine,'solve',[x+z>2*y,z>y,2*z>2*x,x>0,y>0,z>0],[x y z]))
    ~isempty(feval(symengine,'solve',[x+z>2*y,z>y,2*z>2*x,x>0,y>0,z<0],[x y z]))

    The first case returns true, 1, indicating that there is at least one solution. The second returns false, 0, as there is no solution.

    If you want to do this within MuPAD, you can use the is function:


    However, the first case will return UNKNOWN, which is rather difficult to deal with. You may want to use something like the following instead:


    which assumes that only an empty solution, Ø, will have a length of one. (The MuPAD code is two characters, {}, but it displays as one, Ø, has a length of one, and means empty/zero.) There are probably other ways.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>