1.代码
clear close all
syms s t k u r;
x1='2*sin(s)*cos(t)';y1='2*sin(s)*sin(t)';z1='2*cos(s)';
x2='-2*cos(k)*cos(k)';y2='2*sin(k)*cos(k)';z2='u';
subplot(1,2,1);ezmeshc(x2,y2,z2,[0,pi,-2,2]); %绘制圆柱面
hold on;
ezsurf(x1,y1,z1,[-pi,pi,0,pi]); %绘制球面
title(' 球面与圆柱面 ');
hold off;
x3='-2*cos(r)*cos(r)';y3='2*sin(r)*cos(r)';z3='2*sin(r)';
subplot(1,2,2);ezplot3(x3,y3,z3,[0,2*pi]);
title(' 维维安尼(Viviani)曲线 ')
2.运行结果