combining 2 3D Plot

조회 수: 17 (최근 30일)
yogan Sganzerla
yogan Sganzerla 2021년 5월 21일
답변: Uday Pradhan 2021년 5월 24일
Dear, I have some 3D Data as zou can see in the photo bellow. (Bilder 1)
I need to create a cube, in a specific position and plot this cube in the sabe plot where my data is. and the data that are inside of the plot I will not be able to see (because the faces of the Cube will hide) However the points that are outside I will still be able to see them.
For example; Imagem that my cube has the folloing vertices: (-0.5 , 0.5 , 0.5), (0.5 , 0.5 , 0.5), (-0.5 ,-0.5 , 0.5) ,(0.5 ,-0.5 , 0.5), (-0.5 , 0.5 , -0.5), (0.5 , 0.5 , -0.5), (-0.5 ,-0.5 , -0.5), (0.5 ,-0.5 , -0.5).
How to add this cube in the 3D plot above.

답변 (1개)

Uday Pradhan
Uday Pradhan 2021년 5월 24일
Hi,
Please try the below code to achieve what you have asked for:
figure
[X,Y,Z] = sphere(16);
x = [0.5*X(:); 0.75*X(:); X(:)];
y = [0.5*Y(:); 0.75*Y(:); Y(:)];
z = [0.5*Z(:); 0.75*Z(:); Z(:)];
scatter3(x,y,z)
hold on
P = [0,0,0] ; % you center point
L = [1,1,1] ; % your cube dimensions
O = P-L/2 ; % Get the origin of cube so that P is at center
plotcube(L,O,.8,[0 0 0]); % use function plotcube
hold on
plot3(P(1),P(2),P(3),'k')

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by