function parabola %parabola.m produces two images of a paraboloid. n=40; X=ones(n,1)*linspace(-sqrt(2),sqrt(2),n); Y=flipud(X'); for r=1:n for c=1:n if X(r,c)==0 & Y(r,c)==0 elseif abs(X(r,c))<=abs(Y(r,c)) x=X(r,c); y=Y(r,c); X(r,c)=x*abs(y)/sqrt(x^2+y^2)/sqrt(2); Y(r,c)=y*abs(y)/sqrt(x^2+y^2)/sqrt(2); else x=X(r,c); y=Y(r,c); X(r,c)=abs(x)*x/sqrt(x^2+y^2)/sqrt(2); Y(r,c)=abs(x)*y/sqrt(x^2+y^2)/sqrt(2); end end end Z=-X.^2-Y.^2; %create a first image of the parabola fig=figure; set(fig,'color',[1 1 1]) colormap([0 0 0]) mesh(X,Y,Z) grid off axis equal off %create a second image fig=figure; set(fig,'color',[1 1 1]) colormap([0.7 0.7 0.7]) a=surf(X,Y,Z); light lighting gouraud grid off axis equal off set(a,'linestyle','none','facealpha',0.7) hold on %now add red and green lines to the second image. r=linspace(-1,1,n); th1=linspace(0,2*pi,10); for k=1:length(th1) plot3(cos(th1(k))*r,sin(th1(k))*r,-r.^2,'r') end th=linspace(0,2*pi,200); r1=linspace(0.1,1,10); for k=1:length(r1) plot3(r1(k)*cos(th),r1(k)*sin(th),-r1(k)^2*ones(size(th)),'g') end