Info

This question is closed. Reopen it to edit or answer.

Trouble joining to halfs of a plo tto make a full shape.

1 view (last 30 days)
Hello, I am trying to make multiple shapes and am making the top half fine. When I try to join the shape to a bottom by using surf(x,y,z), hold on, surf(x,y,-z) it plots discs instead of shapes. It works fine on plotting a sphere but not an ellipsoid. Here is the code:
a=linspace(0,1,10);
b=linspace(0,1.5,10);
c=linspace(0,2,10);
a1=ones(22,1)*a;
b1=ones(22,1)*b;
c1=ones(22,1)*c;
z1=real(sqrt(1-x.^2/a1'.^2-y.^2/b1'.^2))
z2=z1*ones(10,22)
subplot(2,2,2)
axis equal,axis square
surf(x,y,z2),hold on
title('b')
aaa=linspace(0,1,10);
bbb=linspace(0,1,10);
ccc=linspace(0,.5,10);
aaa1=ones(22,1)*aaa;
bbb1=ones(22,1)*bbb;
ccc1=ones(22,1)*ccc;
zzz1=.5*sqrt(1-x.^2/aaa1'.^2-y.^2/bbb1'.^2);
zzz2=zzz1*ones(10,22);
subplot(2,2,3);
axis equal
surf(x,y,zzz2)
title('c')
aa=linspace(0,1,10);
bb=linspace(0,1,10);
cc=linspace(0,1.2,10);
aa1=ones(22,1)*aa;
bb1=ones(22,1)*bb;
cc1=ones(22,1)*cc;
zz1=1.2*sqrt(1-x.^2/aa1'.^2-y.^2/bb1'.^2)
zz2=zz1*ones(10,22)
subplot(2,2,4)
axis equal
surf(x,y,zz2),hold on
surf(x,y,-zz2)
title('d')
Any help would be appreciated. Thanks.
  1 Comment
Patrick Kalita
Patrick Kalita on 7 Feb 2012
This code as it is cannot be run because the variable 'x' is not defined.

Answers (0)

This question is closed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!