参考代码
[x, y] = meshgrid( linspace(-1.5,1.5) );
z = exp(x+2*y-1) .* (x+y>1) + exp(x.^2+y.^2) .* ((-1mesh(x, y, z)
view(30,36)
效果图
二元函数图形的绘制,你试一下,看这样可以不:
clc,clear,clf
r=0;s=0;t=0;
x=-2*pi:.05:2*pi;
y=-2*pi:.05:2*pi;
m=length(x);
n=length(y);
for i=1:m
for j=1:n
if x(i)+y(j)>1
r=r+1;
x1(r)=x(i);
y1(r)=y(j);
elseif x(i)+y(j)>-1&&x(i)+y(j)<=1
s=s+1;
x2(s)=x(i);
y2(s)=y(j);
elseif x(i)+y(j)<=-1
t=t+1;
x3(t)=x(i);
y3(t)=y(j);
end
end
end
ezsurf('exp(x+2*y-1)',[min(x1),max(x1),min(y1),max(y1)])
hold on
ezsurf('exp(x^2+y^2)',[min(x2),max(x2),min(y2),max(y2)])
hold on
ezsurf('exp(x^2-y^2)',[min(x3),max(x3),min(y3),max(y3)])
可这样:
x=-2:0.05:2;
y=x;
[x,y]=meshgrid(x,y);
z=exp(x.^2-y.^2).*(x+y<=-1)+exp(x.^2+y.^2).*(-1
mesh(x,y,z)