combining 2 3D Plot
15 views (last 30 days)
Show older comments
yogan Sganzerla on 21 May 2021
Answered: Uday Pradhan on 24 May 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.
Uday Pradhan on 24 May 2021
Please try the below code to achieve what you have asked for:
[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(:)];
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
where the plotcube function is take from: https://www.mathworks.com/matlabcentral/fileexchange/15161-plotcube
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!