MATLAB: Building cylinder using isosurface

cylinderisosurfacepatch

Hello everyone,
I'm trying to create a cylindric patch using the isosurface command. Using this tutorial I created my own structure. The code is the following:
[x,y,z] = meshgrid(-1:.02:1);
blob = z <= 0 & z >= -1 & x.^2 + y.^2 <= sqrt(0.18) & x.^2 + y.^2 >= sqrt(0.15);
p = patch(isosurface(blob,0.5));
set(p, 'FaceColor', 'red', 'EdgeColor', 'none');
view(3)
camlight
alpha(0.3)
lighting gouraud
Now, I want to specify for every level of the cylinder a different radius. The values of the radii for every level are stored in a vector 1×36.
How can I modify the blob accordingly?
Thanks for any suggestions.

Best Answer

I would try using a function
test = @(x) abs( cos(4*x) );
[x,y,z] = meshgrid(-1:.02:1);
blob = z <= 0 & z >= -1 & x.^2 + y.^2 <= ...
sqrt(0.18*test(z)) & x.^2 + y.^2 >= ...
sqrt(0.12*test(z));
In this way you will get a wobbly thing depending on the z coordinate.
Related Question