I get this error when trying to use fminunc "Error using message/getString Unable to load a message catalog 'optim:fminusub'. Please check the file location and format."
31 views (last 30 days)
Show older comments
I have this code in one .m file :
%%HW 2 example
% first define polynomial function and display
clear
x = -3:0.1:3 ;
y = (x+1) .* (x+1) +1;
%% Next find the unconstrained minimum
x0 = 3;
options = optimoptions('fminunc', 'Display', 'iter', 'Algorithm', 'quasi-newton');
[xoptimal, optimal_cost] = fminunc(@hw2_example_cost, x0, options)
figure
plot(x,y,'k-'); grid; hold on
h1 = plot(xoptimal, optimal_cost,'ko');
set(h1, 'markersize', 10, 'linewidth', 2, 'MarkerFaceColor', '#D9FFFF');
title('Unconstrained Optimization Minimum')
-------------------------------------------------------------------------
and this code in another .m file (to use in the fminunc)
function cost = hw2_example_cost(x)
cost = (x + 1) * (x + 1) + 1;
end
-----------------------------------------------------------------------------
this is the error message in the command line (when my proffesor runs it he gets it to work no problem)
Error using message/getString
Unable to load a message catalog 'optim:fminusub'. Please check the file location and format.
Error in createExitMsg (line 32)
basicMsg = getString(message(basicMsgArgs{:}));
Error in fminusub (line 322)
output.message = createExitMsg(msgData{:});
Error in fminunc (line 496)
[x,FVAL,GRAD,HESSIAN,EXITFLAG,OUTPUT] = fminusub(funfcn,x, ...
Error in hw2_example (line 12)
[xoptimal, optimal_cost] = fminunc('hw2_example_cost', x0, options)
--------------------------------------------------------------------------------------------------------------------
I was using MATLAB2023B at first but since i got this error i switched to my proffesors version (2023A) and i still get the same error. And no i did not mix different verisons files of matlab together or do anything weird during instalation process. I only have 1 version of matlab downloaded right now.
6 Comments
Dyuman Joshi
on 5 Feb 2024
Weird. If you did not have the Optimization toolbox installed, you should have gotten an error like this when you ran your code -
" 'fminunc' requires Optimization Toolbox. "
Answers (1)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!