Try this:
a = linspace(0, 2*pi); ra = 1; rb = 5; apex = [rb*cos(a); ra*cos(a)]; base = [rb*sin(a)+rb; ra*sin(a)+ra]; h = 10; z = [h*ones(size(a)); zeros(size(a))];
figure(1) surf((apex), (base), z) axis equal shading interp view(80,30)
Try this:
a = linspace(0, 2*pi); ra = 1; rb = 5; apex = [rb*cos(a); ra*cos(a)]; base = [rb*sin(a)+rb; ra*sin(a)+ra]; h = 10; z = [h*ones(size(a)); zeros(size(a))];
figure(1) surf((apex), (base), z) axis equal shading interp view(80,30)
You can certainly rename them and then switch their order in the surf call. Note that ‘apex’ and ‘base’ are each (2x100) matrices. The x-coordinates are cos values, and the y-coordinates are sin values, each forming a different circle. The exact order doesn’t matter, so long as the two circles get drawn. The z-coordinate (another (2x100) matrix) displaces them in the third dimension, forming the cone.
And you’re correct about the structure of z. If you want the z-coordinates to be different, use this:
z = [h1*ones(size(a)); h2*ones(size(a))];
That will plot one circle at ‘h1’ and the other at ‘h2’, forming the cone between those values.
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!