MATLAB: How to sketch correctly

double integralMATLABvolume in polar coordinate

I got this question:
Evaluate the volume V of the solid Ω that lies under the paraboloid z = x^2+y^2 , and above the circular region in the xy−plane x^2 + y^2 = 2x. Sketch the given solid.
This is what I have done, I do not know how to erase the extra part so that I can get the solid satisfying the question. Can anyone help me solving this issue?
Thank you for reading.
%Calculation
syms r phi
func = r.^3;
rmax = 2.*cos(phi);
result = int(int(func, 0, rmax), 0, 2*pi);
disp('Result: '), disp(result);
%draw the paraboloid
phi = linspace (0, 2*pi, 30);
r = linspace(0, 2, 30);
[r, p] = meshgrid(r, phi);
x = r.*cos(p);
y = r.*sin(p);
z = x.^2 + y.^2;
surf(x, y, z, 'FaceColor', 'g', 'FaceAlpha', 0.3);
hold on
%draw the cylinder
x1 = linspace(0, 2, 500);
z1 = linspace(0, 4, 500);
[x1,z1] = meshgrid(x1,z1);
y1 = sqrt(-x1.^2 + 2.*x1);
y2 = -sqrt(-x1.^2 + 2.*x1);
surf(x1, real(y1), z1,'FaceColor','b','FaceAlpha',0.5,'EdgeColor','none'); %real for drawing complex number
hold on;
surf(x1, real(y2), z1,'FaceColor','b','FaceAlpha',0.5,'EdgeColor','none');
hold on;
xlabel('x');
ylabel('y');
zlabel('z');
rotate3d on

Best Answer

Here is a start
  • try this line to draw the part you are interested in
z1 = (x/2+1).^2 + y.^2/4;
surface(x/2+1, y/2, z1, 'FaceColor', 'r');
DOes it look familiar to you?