Generate a Hexagonal Array

24 Ansichten (letzte 30 Tage)
Yrobel Lima
Yrobel Lima am 25 Sep. 2017
Bearbeitet: Image Analyst am 11 Jun. 2021
How can I make a hexagonal arrangement? I have a series of data that make up an array and I want to express it as a hexagonal map like figure.
Thanks a lot
  3 Kommentare
Image Analyst
Image Analyst am 11 Feb. 2021
@davod naghavi, we don't know. He never accepted any of the answers below. But since it's been over 3 years, I'd assume it was solved. And I doubt he'll answer you. Regardless, you can also look at the answers below and get your own solution.
davod naghavi
davod naghavi am 12 Mai 2021
Thank you Dear @Image Analyst

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Image Analyst
Image Analyst am 25 Sep. 2017
It's been talked about a lot before. Just search for it: https://www.mathworks.com/matlabcentral/answers/?term=tag%3A%22hexagon%22 and I'm sure you'll find code that you can adapt.

Stijn Haenen
Stijn Haenen am 7 Okt. 2019
base=1;
X=[];
Y=[];
for num=1:6
x=zeros(num*6,1);
y=zeros(num*6,1);
x(1:6)=base*num*cos(2*pi/6.*(0:5));
y(1:6)=base*num*sin(2*pi/6.*(0:5));
if num>1
for q=1:num-1
start_x=x(2)-q*base;
radi0=sqrt(start_x^2+y(2)^2);
start_alpha=1/3*pi+pi*1/3*1/(num)*q;
x(q*6+1:q*6+6)=radi0*cos(start_alpha+pi/3.*(1:6));
y(q*6+1:q*6+6)=radi0*sin(start_alpha+pi/3.*(1:6));
end
end
X=[X; x];
Y=[Y; y];
end
scatter(X,Y)
  6 Kommentare
Yro
Yro am 11 Jun. 2021
Bearbeitet: Yro am 11 Jun. 2021
Hi everyone,
The problem raised above I had done it with another account a few years ago. I found a solution using the scatteredInterpolant function in Matlab. Here I share a code in case it can help you.
Thanks in advance.
figure('rend','opengl','pos',[400 200 1024 720]);
% X -> vector (x coordinates)
% Y -> vector (y coordinates)
% Z -> vector (reactor power values)
% These arrays were taken from the simulation code
F = scatteredInterpolant(X,Y,Z,'nearest');
[X,Y] = ndgrid(linspace(min(X),max(X),1500),linspace(min(Y),max(Y),1500));
Z = F(X,Y);
POWER_map = surf(X, Y, Z, 'edgecolor', 'none');
R_FA = lattice_pitch/2;
Rx_Core = 11*R_FA; % Core radius
limitx = Rx_Core ;
ylim([-limitx limitx]);xlim([-limitx limitx]);
axis('square','off')
colormap('jet')
box off
grid on
view(a,90); % Vista en XY
% If you want to add values to each hexagon
xtext = COORDX(:,i);
ytext = COORDY(:,c);
ztext = POWER_FULL_CORE;
ztext(ceros) = NaN;
strmax = num2str(ztext,3);
t2 = text(xtext,ytext,ztext,strmax,'HorizontalAlignment','center','VerticalAlignment','middle', 'FontSize', 10);
Image Analyst
Image Analyst am 11 Jun. 2021
Bearbeitet: Image Analyst am 11 Jun. 2021
Nice. Depends on what form @Yrobel Lima wants though. There is also a new nsidedpoly() function that might be what someone wants.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by