Minimizing a multivariable function

조회 수: 5 (최근 30일)
imren bayil
imren bayil 2018년 3월 17일
댓글: Star Strider 2018년 3월 17일
function b=three_var(v)
x=v(1);
y=v(2);
z=v(3);
b=(x-10)^2+(y-4)^2+(z-0.9)^2+3*(1-x*y*z)^2
v=[5,5,5];
a=fminsearch(@three_var,v)
I would like to find minumum multivariable function in matlab
f(x,y,z)=(x-10)^2+(y-4)^2+(z-0.9)^2+3*(1-x*y*z)^2 (x0,y0,z0)=(5,5,5)
ı tried above solution but it has error can anybody help me please

답변 (1개)

Star Strider
Star Strider 2018년 3월 17일
Your code works for me as you posted it. (I added an end as the last line of the function, because I have a test function I use to test functions, and that requires the end call.)
With that one change, I got these results:
a =
9.997810194891304
3.994471169491158
0.025222197590888
  댓글 수: 2
imren bayil
imren bayil 2018년 3월 17일
when I run this code,it writing Error using Untitled (line 2) Not enough input arguments.
Star Strider
Star Strider 2018년 3월 17일
I have no idea what you are doing.
Save your function in its own file in your MATLAB search path as three_var.m. Then run these lines from your script:
v=[5,5,5];
a=fminsearch(@three_var,v)

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by