find the absolute maximum and minimum values of f on the set D
10 次查看(过去 30 天)
显示 更早的评论
f(x,y)=exp.^(-x^2-y^2)(x^2+2y^2) with D is the disk x^2 + y^2 <=4
0 个评论
回答(1 个)
Ameer Hamza
2020-6-22
Although you can use fmincon() and specify the nonlinear constraint, this function is multi-modal, and the search region is quite small, so it might be better to use a mesh and search for the smallest and largest value
f = @(x,y) exp(-x.^2-y.^2).*(x.^2+2*y.^2);
[X, Y] = meshgrid(-2:0.01:2);
mask = X.^2 + Y.^2 - 4 <= 0;
X(~mask) = nan;
Y(~mask) = nan;
Z = f(X, Y);
min_val = min(Z, [], 'all');
max_val = max(Z, [], 'all');
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 NaNs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!