combining 2 3D Plot

15 ビュー (過去 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 Center および File Exchange2-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