matlab中 作出函数f(x,y)=y^3⼀9+3*x^2*y+9*x^2+y^2+x*y+9,-2<x<1,-7<y<1的图,观察极值点的位置并求出

2024-11-15 15:28:11
推荐回答(1个)
回答1:

[x,y]=meshgrid(linspace(-2,1,30),linspace(-7,1,30));
f=y.^3/9+3*x.^2.*y+9.*x.^2+y.^2+x.*y+9;
surf(x,y,f);
MAX=imregionalmax(f);
for i=1:1:30
for j=1:1:30
if(MAX(i,j)==1)
hold on;
plot3(x(i,j),y(i,j),f(i,j),'r*');
text(x(i,j),y(i,j),f(i,j),'极大值点');
end
end
end