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

p = plot(F,x,color,npoints,options)

## Examples

We start with plotting constraint objects.

Define a set in R3

x = sdpvar(3,1);
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)

plot(F,[x(1);x(3)])

By default, the feasible set is projected to R3 (the three variables with lowest index in YALMIP)

plot(F)

The feasible set when x1=0.5

plot(replace(F,x(1),0.5))

Since x1 is eliminated, the plot is performed in the remaining two variables. Equivalently

plot([F,x(1)==0.5],x(2:3))

A third argument can be used to control the color

plot(F,[],'b')

A fourth argument can be used to control the accuracy (the number of rays shot to estimate the feasible set)

plot(F,[],[],150)

The fifth argument can be used to pass an options structure for the solver

plot(F,[],[],[],sdpsettings('solver','sedumi','verbose',0));

Additionally, sdpsettings has some options to control the plot

plot(F,[],[],[],sdpsettings('verbose',0,'plot.wirestyle','none'));

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.

plot([F,-100 <= recover(depends(F)) <= 100]);

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.

sdpvar x
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.)