I tried to use the code below to plot 2 concentric hexagons but I am having problems with their width and more problems when I try to increase the hexagons to three. Any help will be appreciated.
clcclear allscale=4;scale0=5;L = linspace(0,2.*pi,7);% N_sides = 6;
% L=(1/(N_sides*2):1/N_sides:1)';
% L=L*2*pi;
% L1=L;
xv = cos(L)'; xz = cos(L)';yv = sin(L)'; yz = sin(L)';xv=scale*[xv; xv(1)]; xz =scale0*[xz; xz(1)];yv=scale*[yv; yv(1)]; yz =scale0*[yz; yz(1)];% xv = [xv ; xv(1)]; yv = [yv ; yv(1)];
% xz = [xz ; xz(1)]; yz = [yz ; yz(1)];
x = rand(50); y = rand(50);v = rand(20); w = rand(20);in = inpolygon(x,y,xv,yv);inz = inpolygon(v,w,xz,yz);figureplot(xv,yv,x(in),y(in),'r+',x(~in),y(~in),'bo')holdplot(xz,yz,v(inz),w(inz),'b+',v(~inz),w(~inz),'ro')A=numel(y(in)), b=numel (x(~in))C=numel(v(inz)), d=numel (w(~inz))
Best Answer