Adding z-values for surf/contour plots
11 views (last 30 days)
Hi! I have a cone which I can plot two times with a minor displacement like this:
p=0:1:40; [X,Y,Z] = cylinder([10 0]); Z=Z*length(p);
axis equal; surf(X,Y,Z) hold on surf(X+3,Y+4,Z)
However, what I would like to do is to add the z-values for the cones wherever they might intersect. Thus creating more of a mountain-like shape. My code is probably completely wrong for what I want to do, but hopefully it at least might show what I´m after.
Is this possible?
Matt Tearle on 21 Feb 2011
Is this what you're after? I'm not sure if you mean "add" the z-values literally (z1 + z2) or "add" in the sense of append to the plot. For the former interpretation:
[x,y] = meshgrid(-10:0.2:15);
z1 = 42 - 4.2*sqrt(x.^2+y.^2);
z2 = 42 - 4.2*sqrt((x-3).^2+(y-4).^2);
z1(z1<0) = 0;
z2(z2<0) = 0;
z3 = z1+z2;
To get rid of the "land" at z = 0, you can also do: