Matlab: 平行截面法绘制由曲面z=x^2-2y^2构成的马鞍面形状


clc,clear,close all;
clf;
a=-20;
eps0=1;
[x,y]=meshgrid(-10:0.2:10);
v=[-10 10 -10 10 -100 100];
z1=(x.^2-2*y.^2)+eps0;
z2=a*ones(size(x));
r0=abs(z1-z2)<=eps0;
zz=r0.*z2;
xx=r0.*x;
yy=r0.*y;
subplot(2,2,2);
h1=plot3(xx(r0~=0),yy(r0~=0),zz(r0~=0),'+');
set(h1,'markersize',2),hold on,axis(v),grid on;
subplot(2,2,1);
mesh(x,y,z1);
grid;
hold on;
mesh(x,y,z2);
h2=plot3(xx(r0~=0),yy(r0~=0),zz(r0~=0),'.');
set(h2,'markersize',6),hold on,axis(v);
for i=1:5
    a=70-i*30;
    z2=a*ones(size(x));
    r0=abs(z1-z2)<=1;
    zz=r0.*z2;
    xx=r0.*x;
    yy=r0.*y;
    subplot(2,2,3);
    mesh(x,y,z1);
    grid,hold on;
    mesh(x,y,z2);
    hidden off;
    h2=plot3(xx(r0~=0),yy(r0~=0),zz(r0~=0),'.');
    axis(v);
    grid on;
    subplot(2,2,4);
    h4=plot3(xx(r0~=0),yy(r0~=0),zz(r0~=0),'o');
    set(h4,'markersize',2);
    hold on;
    axis(v);
    grid on;
end

效果:


  • 7
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值