필터 지우기
필터 지우기

Error while applying fminunc : fun must be a function

조회 수: 1 (최근 30일)
Tushar Shinde
Tushar Shinde 2017년 1월 31일
답변: Walter Roberson 2017년 1월 31일
Hi, I have just started learning and using matlab functions. I wanted to minimize simple quadratic function as follows:
fun = x.^2
x0 = 10
[x, fval] = fminunc(fun, x0)
I was expecting o/p as x=0 fval=0 but instead it gave me: fun should be a function or string or inline....
It is such a simple script. Where am I going wrong?
Thanx in advance :)

답변 (1개)

Walter Roberson
Walter Roberson 2017년 1월 31일
fun = @(x) x.^2

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by