MATLAB: Find minimum of double-variable function on fixed interval

fminbndfunction

Hi every body I have this function : y=(G*r)/4 + ((G^2*r^2)/16 + (G*r)/4 – 1/4)^(1/2) + 1/2 and I would calculated the minimum of this, in 0:1 interval for both of variable.
How I can write their code?
regards

Best Answer

y = @(G,r) abs((G*r)/4 + ((G^2*r^2)/16 + (G*r)/4 - 1/4)^(1/2) + 1/2);
yx = @(x) y(x(1), x(2));
A = [];
Aeq = [];
b = [];
beq = [];
lb = [0 0];
ub = [1 1];
[x, fval] = fmincon(yx, [rand(), rand()], A, b, Aeq, Beq, lb, ub);
Note: that particular function's minimum value of 1/sqrt(2) occurs over almost all of the region, so the location of the minimum is not unique.