build-in optimization function for discrete date
显示 更早的评论
I have a bivariate function with 100 known coordinate points. I want to find which one of these 100 points minimizes the function value. Is there any built-in MATLAB function for this? The optimization problem is straightforward, and I don't need a complex optimization algorithm, just one with sufficiently low time complexity.
回答(1 个)
So you have the function values at 100 different points and you want to know for which of those points the function takes on its minimum value? Just call min on the array of function values with two outputs.
coords = rand(10, 2);
z = peaks(coords(:, 1), coords(:, 2));
% Just store the coordinates and value in a table for easy viewing
results = table(coords(:, 1), coords(:, 2), z, 'VariableNames', ["x coord", "y coord", "z"])
[minimumValue, minimumLocation] = min(z)
To identify the coordinates where the minimum value in z is located:
coordinatesWhereMinimumOccurs = coords(minimumLocation, :)
类别
在 帮助中心 和 File Exchange 中查找有关 Nonlinear Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
