Which function to use for plotting a polygon with 4 coordinates ?

I have a list of sets of 4 coordinates..(x1, y1)(x2, y2)(x3, y3)(x4, y4) and an intensity value associated with a set of four coordinates.
I need to plot a figure connecting these four points and as many figures as there are sets in the list in one Plot. Also, I need to color each polygon with a color specified by a number(intensity value).
How can it be achieved ?

 Accepted Answer

x=[x1 x2 x3 x4]
y=[y1 y2 y3 y4 ]
fill(x,y,'r')
Example
x=[0 2 3 2.5 1 0];
y=[0 0 1 2 2 0]
plot(x,y) % to plot polygon
fill(x,y,'g') % to fill the polygon

4 Comments

Thanks Azzi.
Can you please tell me how can I change the color of based on the an intensity value. Each polygon in the plot will have a different intensity value.
Hey, I got how to change the color by specifying color in form of a vector.
Thank you so much.
You can add
transparency=0.3; % values between 0 and 1
alpha(transparency);

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!