How to plot random shapes within hexagon?
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi ! Urgent Help please. I have plotted two overlapping hexagons, inside them points are randomly generated. I have to sectorize the whole area of hexagons into smaller regions( these regions are random shapes). previously I did this in this way(as in attached figure). Now instead of this (these smaller hexagons inside big ones) i need random shapes. I have plotted a random shape by using the following code:
degree = 5;
numPoints = 1000;
blobWidth = 5;
theta = 0:(2*pi)/(numPoints-1):2*pi;
coeffs = rand(degree,1);
rho = zeros(size(theta));
for i = 1:degree
rho = rho + coeffs(i)*sin(i*theta);
end
phase = rand*2*pi;
[x,y] = pol2cart(theta+phase, rho+blobWidth);
plot(x,y)
Using this code i get a random shape. I need to plot this type of multiple shapes adjacent to each other( no shape overlap other)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/166040/image.jpeg)
within the area of hexagons, but am not able to do this. kindly help me out. Thank You
댓글 수: 0
답변 (1개)
Mahamod ISMAIL
2017년 8월 5일
close all clear all
degree = 5; numPoints = 1000; blobWidth = 5; theta = 0:(2*pi)/(numPoints-1):2*pi; coeffs = rand(degree,1); rho = zeros(size(theta)); for i = 1:degree rho = rho + coeffs(i)*sin(i*theta); end phase = rand*2*pi; [x,y] = pol2cart(theta+phase, rho+blobWidth); plot(x,y); hold on
plot(x+3,y-2)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!