From: striker on
Hi all!! i m working on parametric equations of superellipsoid.my problem is that i cannot create the 3D graph which is expected to be geneterated by this program.
i have used built in functions like 'surf''surfl''plot3' to no use.kindly guide me what to do to create the required 3D graph.

n1=1;
n2=1;
rx=10;ry=20;rz=30;
phi=180:180;
theta=-90:90;

x=(rx)*((sin(theta))^n1)*((cos(phi))^n2);
y=(ry)*((sin(theta))^n1)*((sin(phi))^n2);
z=(rz)*(sin(theta))^n1;
surf(x,y,z);
From: ImageAnalyst on
Here's a similar situation snipped from the demo for the 3D watershed
function. Maybe you can adapt it.
By the way, you want to use .* and .^ instead of * and ^
And you want to use sind() and cosd() instead of sin() and cos().
Regards,
ImageAnalyst


% 1. Make a 3-D binary image containing two overlapping
spheres.

center1 = -10;
center2 = -center1;
dist = sqrt(3*(2*center1)^2);
radius = dist/2 * 1.4;
lims = [floor(center1-1.2*radius) ceil(center2+1.2*radius)];
[x,y,z] = meshgrid(lims(1):lims(2));
bw1 = sqrt((x-center1).^2 + (y-center1).^2 + ...
(z-center1).^2) <= radius;
bw2 = sqrt((x-center2).^2 + (y-center2).^2 + ...
(z-center2).^2) <= radius;
bw = bw1 | bw2;
figure, isosurface(x,y,z,bw,0.5), axis equal, title('BW')
xlabel x, ylabel y, zlabel z
xlim(lims), ylim(lims), zlim(lims)
view(3), camlight, lighting gouraud