二元函数绘图并求极值。

函数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.

 Accepted Answer

cadon
cadon on 24 Nov 2022

0 votes

表达式里 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)

More Answers (0)

Categories

Find more on MATLAB 快速入门 in Help Center and File Exchange

Tags

Asked:

on 24 Nov 2022

Answered:

on 24 Nov 2022

Community Treasure Hunt

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

Start Hunting!