How to fix "fsolve stopped because it exceeded the function evaluation limit" while using fsolve function?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Recently, i'm trying to solve a nonlinear equation set by using "fsolve" . I created my personal function as the following:
function F = poSTAR_14(x,Hm_RI,at_RI,J)
F1=Hm_RI*x;
F2=at_RI*x-[1;0];
F3=x(1:J,1).^2+x(J+1:2*J,1).^2-ones(J,1);
F=[F1(:);F2(:);F3(:)];
end
Above is the function that contains 3 nonlinear equations and I saved it as a .m file with my main file.
Below is the part that I call the fsolve to solve my problem, where
,
are known vetors,
is known scalar, initial point ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/801994/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/801979/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/801984/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/801989/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/801994/image.png)
Hm_R=real(Hm).*100;
Hm_I=imag(Hm).*100;
Hm_RI=[Hm_R,-Hm_I;Hm_I,Hm_R];
at_R=real(as_ele_Tx.');
at_I=imag(as_ele_Tx.');
at_RI=[at_R,-at_I;at_I,at_R];
w_R=real(conj(W_Tx));
w_I=imag(conj(W_Tx));
fun = @poSTAR_14;
x0 = [w_R;w_I];
x = fsolve(@(x)fun(x,Hm_RI,at_RI,J),x0);
But something is wrong with my code and the command window showed that,
Solver stopped prematurely.
fsolve stopped because it exceeded the function evaluation limit,
options.MaxFunctionEvaluations = 6.400000e+03.
Does it mean I should pick a better starting point or just set a larger "MaxFunctionEvaluations"?
I also modified the parameters as below,
options = optimoptions(@fsolve, 'MaxFunctionEvaluations', 10000, 'MaxIterations', 10000);
x = fsolve(@(x)fun(x,Hm_RI,at_RI,J),x0);
but the command window showed the same output.
So why it showed this output and how to fix it?
6 comentarios
Matt J
el 17 de Nov. de 2021
Yes, but without the input data like Hm and as_ele_Tx, there is still no way to run the code.
Respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!