Plotting a Hexagon shape in matlab

조회 수: 28 (최근 30일)
Aftab Ahmed Khan
Aftab Ahmed Khan 2014년 6월 18일
댓글: Aftab Ahmed Khan 2014년 6월 18일
Hi everyone, I have this user distribution on the plane (as shown in the figure). I want to draw a Hexagon shape around these marks. Don't know how to put in there. Thank you so much.
  댓글 수: 1
Aftab Ahmed Khan
Aftab Ahmed Khan 2014년 6월 18일
Even, i have managed to do this, but how can i make all the users inside of this hexagon.

댓글을 달려면 로그인하십시오.

채택된 답변

David Sanchez
David Sanchez 2014년 6월 18일
To Draw any polygon:
scale = 5;
N_sides = 6;
t=(1/(N_sides*2):1/N_sides:1)'*2*pi;
x=sin(t);
y=cos(t);
x=scale*[x; x(1)];
y=scale*[y; y(1)];
plot(x,y)
axis square
Now just hold on and off your data plot. Adjust the scale to your data
  댓글 수: 3
Image Analyst
Image Analyst 2014년 6월 18일
You might want to look at convhull() - a related function that gives a boundary like you'd get if you wrapped a rubber band around your points.
Aftab Ahmed Khan
Aftab Ahmed Khan 2014년 6월 18일
Yes, that was also useful.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by