MATLAB: Function used in fsolve with array coefficients

array coefficientsfsolvefunctionsfunctions with array elements of varying lengthOptimization Toolboxsolving nonlinear equations

Do you have access to the Symbolic Toolbox?

Best Answer

You should be passing ai to MyFun. The size of the ai array can be determined inside MyFun, and from that the number of coefficients.
Xi=fsolve(@(x)MyFun(x,ai),X0) ;
function out=MyFun(x,ai)
[m,n]=size(ai);
out=...
end