Error in fminunc function line 477

조회 수: 4 (최근 30일)
Adriane Moura
Adriane Moura 2021년 8월 30일
댓글: Dyuman Joshi 2023년 12월 19일
The fminunc function gives the error below any time I try to use the function, even for the simple example listed in the MATLAB help. Is the fminunc function corrupted on my computer?
fun = @(x)3*x(1)^2 + 2*x(1)*x(2) + x(2)^2 - 4*x(1) + 5*x(2);
x0 = [1,1];
[x,fval] = fminunc(fun,x0)
***************
Error using message/getString
An unknown error occurred in accessing the Message Catalog.
Error in createExitMsg (line 56)
stopCriteriaDetails = getString(message('optimlib:commonMsgs:StopCriteriaDetails',detailedMsgCmd));
Error in fminusub (line 301)
output.message = createExitMsg(msgData{:});
Error in fminunc (line 472)
[x,FVAL,GRAD,HESSIAN,EXITFLAG,OUTPUT] = fminusub(funfcn,x, ...
***************
  댓글 수: 4
Sohaib Kiani
Sohaib Kiani 2023년 2월 1일
I am getting the same error. Just Installed the fresh copy and didn't modify anything but fminunc is throwing the same error.
Christopher
Christopher 2023년 4월 19일
I am getting the same error. This is my first time installing Matlab.

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

답변 (2개)

Steven Lord
Steven Lord 2023년 4월 19일
Let's check that you haven't written or downloaded a file that's conflicting with a function provided by MATLAB. What do the following two commands show when you run them on your system?
which -all message
message is a built-in method % message constructor /MATLAB/toolbox/matlab/lang/message.m % Shadowed /MATLAB/toolbox/shared/dsp/filterdesignlib/@FilterDesignBlockDialog/message.m % FilterDesignBlockDialog method /MATLAB/toolbox/signal/sigtools/@siggui/message.m % siggui method
which -all getString
getString is a Java method % com.mathworks.mde.desk.MLDesktop method getString is a Java method % com.mathworks.widgets.desk.Desktop method getString is a built-in method % message method getString is a built-in method % matlab.internal.Catalog method getString is a Java method % java.util.ResourceBundle method getString is a Java method % java.util.PropertyResourceBundle method
If you see entries that are not "a built-in method", "a Java method", or a file under matlabroot you may need to rename or remove those other files. Renaming would be safer, as you could always change the name back if absolutely necessary. Leave anything under matlabroot alone.

Álvaro Pérez Fernández
Álvaro Pérez Fernández 2023년 12월 19일
Hi, Adriane,
I was getting the same error until I installed the Optimization Toolbox software for Matlab. Maybe that would fix your problem too.
  댓글 수: 3
Álvaro Pérez Fernández
Álvaro Pérez Fernández 2023년 12월 19일
Well, all I can say is that it happened to me. I was getting the forenamed error while using fminunc. However, fminsearch worked fine. Then I tried fmincon for another problem and Matlab showed me a message asking me to install the Optimization Toolbox in order to use that function. And after installing the toolbox I ran once again the script with fminunc and it worked.
Before installing the toolbox I checked the files mentioned by Steven and I got the same results as him. So the error was not due to a conflict between a file and a Matlab function.
Dyuman Joshi
Dyuman Joshi 2023년 12월 19일
Because there's a built-in function named fminsearch as well, similar to the one from the Optimization toolbox.
So, fminsearch() works without the optimization toolbox, but fminunc, which has no built-in counterpart, requires Optimization toolbox.

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

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by