how to define a 3D volume in a matrix
Show older comments
I need to define a cylinder(diameter=20cm and height=25cm) in a 3D matrix A(40x40x50) such that each element represents a 5mm x 5mm x 5mm cube. Cube A(i,j,k)=1 if it falls within the cylinder and A(i,j,k)=0 if it falls outside the cylinder. What's the best way to populate this matrix?
Accepted Answer
More Answers (1)
Walter Roberson
on 29 Jun 2012
0 votes
If you are aligning the cylinder with a primary axes, then you can create a filled circle and copy that circle along the axes (e.g., repmat)
You do have to be a bit careful about what you mean by "if it falls within the cylinder", when you examine the edge cubes. Even a cube whose center falls within the radius does not necessarily have half of its volume inside the cylinder.
Categories
Find more on Surface and Mesh 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!