build-in optimization function for discrete date
Show older comments
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.
Answers (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, :)
Categories
Find more on Nonlinear Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!