二元函数绘图并求极值。

函数g=0.2*sqrt(2*pi*b/(a.^2-1))*log(sqrt(a+(a.^2+b.^2))/(1+sqrt(1+b.^2)))做出三维图形,并求出极值,其中0<=x<=10,0<=y<=10.

 采纳的回答

cadon
cadon 2022-11-24

0 个投票

表达式里 a 是 x,b 是 y 吗?如果是的话,a 不能小于 1,否则 a.^2-1 为负数,外面的sqrt就会得到复数
所以你的 x 的范围似乎应该是1到10
g=@(a,b) 0.2*sqrt(2*pi*b./(a.^2-1)).*log(sqrt(a+(a.^2+b.^2))./(1+sqrt(1+b.^2)));
[x,y] = meshgrid(1:0.1:10, 0:0.1:10);
mesh(x,y,g(x,y))
lb = [1 0]; ub = [10 10];
x0 = (lb+ub)/2;
options = optimset('Algorithm','interior-point');
x = fmincon(@(x) g(x(1),x(2)),x0,[],[],[],[],lb,ub,[],options)

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 MATLAB 快速入门 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!