MATLAB: Function ‘fsolve’ not supported for code generation.

codegenfsolveMATLABmatlab coderoptimoptions

Hi all,
I was trying to generate a mex code from my written code which includes fsolve.
For example, I tried the following as suggested in https://www.mathworks.com/help/optim/ug/generate-code-fsolve.html
function [soln,fval,exitflag]=myfunction(L,l,u,d)
options=optimoptions('fsolve','Algorithm','levenberg-marquardt','Display','off');
fun = @(x)somefunction(x,L,l,u);
[soln,fval,exitflag] = fsolve(fun,zeros(2*(d-1),1),options);
end
%%%%%%%%%%
function someoutput = somefunction(a,L,l,u)
someoutput = a+L+l+u;
end
and ran the MATLAB coder.
However it gives me the error that
OPTIMOPTIONS does not support code generation for function 'fsolve'.
I also tried avoid using optimoptions and instead put the options directly into the function fsolve, which returned the error
Function 'fsolve' not supported for code generation.
It is really confusing as the documentations for both optimoptions and fsolve say that fsolve indeed supports code generation.. Can I get any help why this is happening?
Thank you a lot in advance.
Best,
Dong Woo

Best Answer

Code generation support for fsolve() was added in R2020b, but you have R2020a.