3D hexagonal mesh grid
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hi,
I arranged the x-y space in hexagonal format as a layer. How can I add another similar layer on top with a distance in the z-direction?
I appreciate your help.
Thanks a lot,
채택된 답변
V=nsidedpoly(6).Vertices;
[X,Z]=ndgrid(V(:,1),0:3);
[Y,~]=ndgrid(V(:,2),0:3);
scatter3(X(:),Y(:),Z(:)); view(-60,70)
xlabel X; ylabel Y; zlabel Z

댓글 수: 7
I arranged the x-y system with the code bellow:
m = 6;
n = 7;
[x,y] = meshgrid(0:m, 0:n);
X = (3*x - mod(x+y,2)) / 2;
X=X+0.5;
X=X(4:8,1:4);
Y = (sqrt(3)/2)*y;
Y=Y(4:8,1:4);
Y=Y-Y(1,1);
plot(X,Y,'or');

As you can see, it is shown in a 2D space. Now, I want to show it in a 3D space with various z values (z is constant for each layer) using this code:
m = 6;
n = 7;
[x,y,z] = meshgrid(0:m, 0:n, 0:1);
x = (3*x - mod(x+y,2)) / 2;
x = x+0.5;
x = x(4:8,1:4,:);
y = (sqrt(3)/2)*y;
y=y(4:8,1:4,:);
y=y-y(1,1);
z=z(4:8,1:4,:);
Dyuman Joshi
2023년 10월 18일
What is the expected output?
S. Hannan
2023년 10월 18일
Showing a multilayer system.
It would help to have a visual example of the expected output.
From what I understood of the provided description -
m = 6;
n = 7;
[x,y] = meshgrid(0:m, 0:n);
X = (3*x - mod(x+y,2)) / 2;
X=X+0.5;
X=X(4:8,1:4);
Y = (sqrt(3)/2)*y;
Y=Y(4:8,1:4);
Y=Y-Y(1,1);
X = X(:);
Y = Y(:);
z_values = [0 0.5 1];
figure
for k=z_values
plot3(X,Y,k*ones(size(X)),'o','Color', rand(1,3))
hold on
end
%end
hold off

Do you want to join the dots in each 2D layer?
S. Hannan
2023년 10월 18일
Thanks a lot.
No, I don't need to connect them.
Matt J
2023년 10월 18일
Now, I want to show it in a 3D space with various z values (z is constant for each layer) using this code:
I don't know what you think this changes about my answer. Isn't this what you want?
m = 6;
n = 7;
[x,y] = meshgrid(0:m, 0:n);
X = (3*x - mod(x+y,2)) / 2;
X=X+0.5;
X=X(4:8,1:4);
Y = (sqrt(3)/2)*y;
Y=Y(4:8,1:4);
Y=Y-Y(1,1);
V=[X(:),Y(:)];
[X,Z]=ndgrid(V(:,1),0:3);
[Y,~]=ndgrid(V(:,2),0:3);
scatter3(X(:),Y(:),Z(:)); view(-70,83)
xlabel X; ylabel Y; zlabel Z

S. Hannan
2023년 10월 19일
Thanks a lot.
Yes. this is the desired structure.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
참고 항목
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
