plot is used to plot the (projection) of the (convex) feasible set (when applied to constraints) and plotting PWA functions (when applied to sdpvar objects)
Syntax
Examples
We start with plotting constraint objects.
Define a set in R3
F = [[1 x(2);x(2) x(1)] >= 0, 3 >= x, [1 x';x eye(3)] >= 0, sum(x) >= x'*x];
Plot the feasible set, projected on (x1,x3)
By default, the feasible set is projected to R3 (the three variables with lowest index in YALMIP)
The feasible set when x1=0.5
Since x1 is eliminated, the plot is performed in the remaining two variables. Equivalently
A third argument can be used to control the color
A fourth argument can be used to control the accuracy (the number of rays shot to estimate the feasible set)
The fifth argument can be used to pass an options structure for the solver
Additionally, sdpsettings has some options to control the plot
To avoid strange looking plots, you should ensure that your feasible set is bounded. One way to that is to add bounds on all involved variables.
The command plot can also be applied to sdpvar objects representing piecewice affine structures (typically returned from solvemp). YALMIP can also automatically create these piecewise structures and plot them using MPT.
plot(max([x -x 1]) + norm(x-1,1))
Comments
Note that plotting the feasible set requires solving an associated optimization problem repeatedly. Hence, for feasible sets defined by a lot of constraints and variables, it may take a long time to generate the figure (controlled by the accuracy level in the fourth argument, 25 points is default for 2D and 100 for 3D figures, although much more is recommended for smooth figures). For small problems, a large portion of the solution time can easily be dominated by overhead costs. Hence, it is recommended to use a solver with low overhead (for SDP problems, PENSDP is recommended)
Also note that when you plot sets with constraints involving nonlinear operators and polynomials, it is recommended that you specify the variables of interest in the second argument (YALMIP may otherwise plot the set with respect to auxiliary variables introduced during the construction of the conic model.)