FMINUNC cannot continue.

1 Ansicht (letzte 30 Tage)
Anyang He
Anyang He am 7 Apr. 2020
Kommentiert: Walter Roberson am 7 Apr. 2020
Hi, I'm trying to learning fminunc, but it gives errors: 'Insufficient number of input parameters' and 'Failure in initial user-supplied objective function evaluation. FMINUNC cannot continue.'
The cose is as following. I have saved the function Pun as a separate file.
Help please?
function f = Pun(x,lamda)
f = x(1)^2 + lamda * x(2)^2;
end
x = [0.5;0.5];
lamda = 0.5;
fminunc('Pun',x,lamda)

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 7 Apr. 2020
  2 Kommentare
Anyang He
Anyang He am 7 Apr. 2020
Thank you very much. I solve the problem by using Nested Functions.
Walter Roberson
Walter Roberson am 7 Apr. 2020
fminunc(@(x) Pun(x,lamda), x)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Entering Commands finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by