fminunc is not working in my equation, can you help me with these errors? i am a beginner in matlab

1 次查看(过去 30 天)
hi.. i am trying to optimize this equation through matlab's fminunc
in the editor i typed:
function F = fun(x,e) F = -0.2662*x.^6 + 48.19*x.^5 - 3424.2*x.^4 + 121708*x.^3 - 2*e^6*x.^2 + 2*e.^7*x - 6*e.^7; end
in the command line i typed the following and at the same time got results shown:
x0= [0,0]; [x, fval] = fminunc (@fun,x0); ??? Undefined function or variable 'e'.
Error in ==> fun at 2 F = -0.2662*x.^6 + 48.19*x.^5 - 3424.2*x.^4 + 121708*x.^3 - 2*e^6*x.^2 + 2*e.^7*x - 6*e.^7;
Error in ==> fminunc at 227 f = feval(funfcn{3},x,varargin{:});
Caused by: Failure in initial user-supplied objective function evaluation. FMINUNC cannot continue.
can you help me fix this?

采纳的回答

Harshvardhan
Harshvardhan 2014-5-22
what are your variables in the function? x can be a vector and when plugged in F should evaluate to a scalar. By the looks of your function 'fun' that doesn't seem to be the case.
  9 个评论
hizaki
hizaki 2014-5-22
oh i am sorry..the result is....
x0 = 0; [x, fval] = fminunc (@fun,x0) Warning: Gradient must be provided for trust-region algorithm; using line-search algorithm instead. > In fminunc at 347
Solver stopped prematurely.
fminunc stopped because it exceeded the function evaluation limit, options.MaxFunEvals = 100 (the default value).
x =
NaN
fval =
NaN

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by