combining 2 3D Plot

17 vues (au cours des 30 derniers jours)
yogan Sganzerla
yogan Sganzerla le 21 Mai 2021
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.

Réponses (1)

Uday Pradhan
Uday Pradhan le 24 Mai 2021
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')

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by