version 1.1.0.0 (10.9 KB) by
Per Bergström

The program plots convex closed regions in 2D/3D.

**Editor's Note:** This file was highlighted in the File Exchange Pick of the Week blog.

The program plots convex closed regions in 2D/3D. The region is a subset of R2 or R3 such that Ax>=b and lb<=x<=ub. It is also possible to plot points in the same plot.

(See help plotregion for more documentation)

Per Bergström (2021). Plot 2D/3D region (https://www.mathworks.com/matlabcentral/fileexchange/9261-plot-2d-3d-region), MATLAB Central File Exchange. Retrieved .

Created with
R12

Compatible with any release

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!Create scripts with code, output, and formatted text in a single executable document.

Shelli255Documentation could be better. Otherwise pretty useful. I have a question, though: Is there a way to rotate and translate objects defined as Ax >= b before plotting them?

sepanta slnDeepak Prakash KThanks for this. Is it not possible to place a point somewhere in the region? I am able to place points only at the extreme points of the region.

Jenny O'JheneThanks for this. it solves my problem perfectly!!

majidI wanted to draw simplex (2D and 3D), and it was bugy! the shape was completely wrong.

Shane LoserAmazing! So useful! Only minor point: Why set up up the region such that Ax>=b, when the standard MATLAB form for linear programming is Ax<=b

GaneshSarah SachsSirvan AhmadiSirvan AhmadiI need to plot the following region. Is there any way to plot it with this package?

a=0: 0.1 :1;

b=0: 0.1 :1;

x<=f(a,b);

y<=g(a,b);

y+x <= k(a,b);

where f, g, and k are nonlinear functions.

Thanks,

Sirvan

Andy Andylufeivery good

HristoExcellent package - works like a charm and gets you experimenting in a second!

NanIs there anybody could tell me what the meaning of

b?Thx

Naftalianswer to song:

ax<=b is euivalent to -ax>=-b

SongIt is very helpful to me. As a beginner for Matlab, I have a question which is how could I modify the program to Ax<=b. Can you help me on it?

Thanks in advance

XiaodongGood stuff! Thanks.

NilsThis is amazing. So easy to visualize complex regions! I love it.

WuMahshidThis is amazing! It was very useful for my purpose (I am developing a GUI to show the steps that simplex takes to solve an optimization problem). But I have a question: is it possible to draw different faces of the polyhedron with different colors? I like to have some nice and colorful figure for the feasible region of the problem which is a polyhedron.

Thanks.

Matt JI like it a lot. As a minor point, though, it would be good if you could return a plot handle as an output argument.

YVery good file. I love it. Thanks for sharing

MagnusThanks for a nice package - it saved me quite some time! A hint to users: You get the error "Vector must have 4, 6, or 8 elements." if you specify an unfeasible set, i.e. if your A and b are such that no x fulfill Ax >= b. In my case, it was because I happened to define the normal vectors so they point out instead of in, i.e., the sign of A was reversed.

Rodrigo Lopezvery good! just what i need for my thesis. Thanks!

Juan Carlos: You can close your polyhedron by adding goods upper and lower bounds.

Thierry DalonGood contribution!

Juan Carlos TrilloI was looking for something similar, great!

Only one question, how can one do to appropiately define the planes to plot general closed regions?

Jianing DiI think it is very useful.

Steven RandolphPA Linteresting

E. HearnI am sure this works well, but it needs clearer documentation. I simply cannot understand the format.

"The region(s) x is a subset of R2/R3 s.t. A*x>=b and lb<=x<=ub" is rather cryptic.

Golnaz Habibimc ka aAmir Ali AhmadiAfter hours of playing around with different m-files, trying to figure out how to fill the region b/w the intersection of some planes in R^3, I found this m-file which took care of the job in less than a minute.

Matlab has a built-in function ?area? for 2-D but nothing for 3-D (to my understanding).

I used plotregion.m to visualize a subset of R^3 where all the vectors have norm-1 less than say 3. (i.e. abs(x)+abs(y)+abs(z)<=3). This is easily done using this m-file by inputting an 8x3 constraint matrix A.

Thanks a lot & great work?

-AAA

Peter LarsenJust what I needed. Thanks.

John D'ErricoSplendid. A very nice utility that I'll happily use. I'd have

liked more documentation in the help, but I tend to go

overboard there myself, so my standards may be deemed

excessive by sane, rational beings. The examples were

enough to figure it out.