Generate a Hexagonal Array
24 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Image Analyst
2021 年 2 月 11 日
@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.
回答 (2 件)
Image Analyst
2017 年 9 月 25 日
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.
0 件のコメント
Stijn Haenen
2019 年 10 月 7 日
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 件のコメント
Yro
2021 年 6 月 11 日
編集済み: Yro
2021 年 6 月 11 日
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
2021 年 6 月 11 日
編集済み: Image Analyst
2021 年 6 月 11 日
Nice. Depends on what form @Yrobel Lima wants though. There is also a new nsidedpoly() function that might be what someone wants.
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!