Find minimum of double-variable function on fixed interval

조회 수: 7 (최근 30일)
Mohammad
Mohammad 2015년 6월 15일
댓글: Walter Roberson 2015년 6월 16일
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

채택된 답변

Walter Roberson
Walter Roberson 2015년 6월 15일
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.
  댓글 수: 9
Mohammad
Mohammad 2015년 6월 16일
just one question if i want find the maximum of that function; what is this code? thanks
Walter Roberson
Walter Roberson 2015년 6월 16일
yx = @(x) -y(x(1),x(2));
that is, minimize the negative.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Titus Edelhofer
Titus Edelhofer 2015년 6월 15일
Hi,
just to be sure: your y is dependent both on G and r and you want to minimize on the square [0..1]x[0..1]?
In this case fmincon from optimization toolbox is your friend, although your function is not real-valued in the entire square. E.g. for G=0.5, r=0.5 the result is complex ...?
Titus
  댓글 수: 3
Walter Roberson
Walter Roberson 2015년 6월 15일
the abs() of the function is 1/sqrt(2) for most of the area, and increases in a region near 0.81 to 1 in G and r. The minimum is therefor going to be 1/sqrt(2)
Mohammad
Mohammad 2015년 6월 15일
After calculating the minimum, i want to find the value which minimum occurred. How i can find minimum of double-variable function?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Direct Search에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by