필터 지우기
필터 지우기

How to find minimum y value numerically using the fminsearch function?

조회 수: 1 (최근 30일)
Bella
Bella 2016년 5월 31일
댓글: Walter Roberson 2016년 6월 1일
For the equation f(x,y)=-8x+x^2+12y+4y^2-2xy... I found the minimum x value by putting the anonymous function using x1 for x and x2 for y then the fminsearch code and got -17.3333. But now I am not sure how to find the minimum y value.

답변 (1개)

Walter Roberson
Walter Roberson 2016년 6월 1일
편집: Walter Roberson 2016년 6월 1일
f = @(x,y) -8*x+x.^2+12*y+4*y.^2-2.*x.*y;
fvec = @(X) f(X(1), X(2));
[bestxy, fval] = fminsearch(fvec, rand(1,2));
bestx = bestxy(1); besty = bestxy(2);
Caution: the solution is not unique! The equation describes an ellipse (or something similar to one.)
  댓글 수: 4
Bella
Bella 2016년 6월 1일
okay, those are the values that I got. So would -2/3 be the minimum y value then? Because it is the lowest of the two?
Walter Roberson
Walter Roberson 2016년 6월 1일
bestx is the x value at the minima. besty is the y value at the minima. Not because it is the lower of the two, but forced because of the order we programmed.

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by