how can i create a cube represented by ones with a cylinder represented by zeros inside
2 views (last 30 days)
Show older comments
I am wondering if somebody can help me create a cube (say NxNxN matrix of ones) which is simply a = ones(N, N, N) but will have a cylinder inside represented by zeros.
Basically, what i want is to have a 3D matrix that has ones and zeros representing the cube encapsulating the cylinder.
Thank you.
0 Comments
Answers (1)
Image Analyst
on 18 Feb 2014
use the FAQ to create a circle. http://matlab.wikia.com/wiki/FAQ?title=FAQ&cb=1158#How_do_I_create_a_circle.3F
Then use cat() or repmat() to replicate the 2d array as many times in the 3D direction as you need. It's easy - give it a try.
2 Comments
Image Analyst
on 18 Feb 2014
Edited: Image Analyst
on 18 Feb 2014
Well those are the easiest ways, but you could just index everything to a plane in the z direction though I don't know why you'd want to do it that way since it's a little trickier. But how you extend into 3D vertically is totally unrelated to having two cylinders intersect, as long as they're parallel.
See Also
Categories
Find more on Logical 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!