Azzera filtri
Azzera filtri

combining 2 3D Plot

12 visualizzazioni (ultimi 30 giorni)
yogan Sganzerla
yogan Sganzerla il 21 Mag 2021
Risposto: Uday Pradhan il 24 Mag 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.

Risposte (1)

Uday Pradhan
Uday Pradhan il 24 Mag 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')

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by