How to fix "fsolve stopped because it exceeded the function evaluation limit" while using fsolve function?
显示 更早的评论
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 
,
are known vetors, 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 个评论
The code you've posted won't run.
H=rand(30,64);
a=rand(2,64);
x0=rand(64,1);
poSTAR_14(x0,H,a,32)
function F = poSTAR_14(x,Hm_RI,at_RI,J)
F(1)=Hm_RI*x;
F(2)=at_RI*x-[1;0];
F(3)=x(1:J,1).^2+x((J+1):2*J,1).^2-ones(J,1);
F=[F1(:);F2(:);F3(:)];
end
奥 刘
2021-11-16
Matt J
2021-11-16
Even if you add it, it still won't run.
奥 刘
2021-11-17
Matt J
2021-11-17
Yes, but without the input data like Hm and as_ele_Tx, there is still no way to run the code.
奥 刘
2021-11-17
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!