'How to pass variable constrains while minimizing function with multiple variables and return the variables?
Assume I have a function with 5 variables, and each one have a range constrains. I want to find the minimum of a function, as well as the values of those 5 variables which are needed to obtain that minimum value in that function. I am using the fminsearch.
func = @(x, y, z, k, m) (--some-function-which-depends-to-those-5-variable);
Assume I have above function that I want to minimize.
range_x = [12, 24];
range_y = [13.3, 30.2];
range_z = [1.4, 4.7];
range_k = [1.2, 1.4];
range_m = [4.12, 12.2];
and the above ranges.
??? = fminsearch(@(x) func(x(1), x(2), x(3), x(4), x(5)), ???)
I am currently using fminsearch function. However, I stucked the point that how can I use ranges and how can I extract the min value / and all those 5 variables which gives this result.
Thanks in advance.
Solution 1:[1]
fminsearch as per the documentation, is for unconstrained minimization, i.e. you don't put limits on the variables.
fmincon instead, is for constrained minimization.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ander Biguri |
