Plot a grid(multiple) cube using the plotcube function
9 views (last 30 days)
Show older comments
I am trying to plot many cubes using the plotcube function without using a for loop. Here's my code...
x = 0:1:1;
y = 0:1:1;
z = 0:1:1;
[X1,Y1,Z1]=meshgrid(x,y,z);
[X2,Y2,Z2]=meshgrid(x,y,z);
[X3,Y3,Z3]=meshgrid(x,y,z);
X1=permute(X1,[2 1 3]); Y1 = permute(Y1,[2 1 3]); Z1= permute(Z1,[2 1 3]);
X1(end+1,:,:)=NaN;Y1(end+1,:,:)=NaN;Z1(end+1,:,:)=NaN;
plotcube([1 1 1],[X1(1,3) Y1(1,3) Z1(1,3)],.2,[0 0 0])
But it only plots one cube.
Something like this...
0 Comments
Answers (1)
Ankriti Sachan
on 28 Oct 2020
Hi,
The image shared by you seems to comprise numerous small cubes of unit edge-length combined to form a large cube.
Based on the syntax of 'plotcube' mentioned on this page - https://www.mathworks.com/matlabcentral/fileexchange/15161-plotcube, you can see that the second parameter is the 'Origin.' From the image displayed above, I believe that passing the array to the 'Origin' parameter, resulted in many cubes, each with a different origin. But, these are just my interpretations. You can contact the owner of this file exchange submission, mentioned in the above link, to get more clarity on how it is implemented.
You can also try plotting one small cube at a time and check if it is displayed as expected in terms of origin, dimension, etc.
0 Comments
See Also
Categories
Find more on Lighting, Transparency, and Shading in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!