How to generate and plot a 3D structured mesh in MATLAB?

조회 수: 31 (최근 30일)
Dr. Mishaal AbdulAmeer AbdulKareem
댓글: darova 2020년 1월 29일
Hi ... I have tried to solve the following problem, but I failed. Can you help me?
Use MATLAB to generate and plot a three-dimensional grid of (6 X 8 X 10) resolution for a (8m X 6m X 5m) rectangular body.
The following is my code and it's not working..!! Help
clear, clc
W=8; % Width
H=6; % Hight
D=5; % Depth
i=6; % Nods number (x-direction)
j=8; % Nods number (y-direction)
k=5; % Nods number (z-direction)
x=linspace(0,W,i); % x
y=linspace(0,H,j); % y
z=linspace(0,D,k); % z
[x,y,z]=meshgrid(x,y,z);
plot3(x,y,z,'ok')

채택된 답변

darova
darova 2020년 1월 28일
Try
[X,Y,Z] = meshgrid(x,y,z);
plot3(X(:),Y(:),Z(:),'ok')
  댓글 수: 4
Dr. Mishaal AbdulAmeer AbdulKareem
A very simple question have such an advanced answer. Thank you very much for your time.
If you don't mind, can you be my first friend in this community... I'm new to this comunity and this was my first question.
I don't know how to invite you.
darova
darova 2020년 1월 29일
of course!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Cameron B
Cameron B 2020년 1월 28일
I’m not sure what all you wanted to do. Is this what you were looking for?
clear
clc
W=8; % Width
H=6; % Hight
D=5; % Depth
i=6; % Nods number (x-direction)
j=8; % Nods number (y-direction)
k=5; % Nods number (z-direction)
x=linspace(0,W,10); % x
y=linspace(0,H,10); % y
z=linspace(0,D,10); % z
plot3(x,y,z,'ok')
xlabel('x label')
ylabel('y label')
zlabel('z label')
  댓글 수: 1
Dr. Mishaal AbdulAmeer AbdulKareem
No, your answer is wrong... Thanks anyway.
The values of i, j and k are not equal and not equal to 10. Focus on my code please.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by