Clear Filters
Clear Filters

Failure in initial objective function evaluation. FSOLVE cannot continue.

7 views (last 30 days)
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)
F(1)=Hm_RI*x;
F(2)=at_RI*x-[1;0];
F(3)=abs(x(1:32,1)).^2+abs(x(33:64,1)).^2-ones(J,1);
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
Hm_R=real(Hm).*100;
Hm_I=imag(Hm).*100;
Hm_RI=[Hm_R,-Hm_I;Hm_R,Hm_I];
at_R=real(as_ele_Tx.');
at_I=imag(as_ele_Tx.');
at_RI=[at_R,-at_I;at_R,at_I];
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 It seems someting wrong with the size of my matrix in the problem formulation:
Unable to perform assignment because the indices on the left side are not compatible with the
size of the right side.
Error in poSTAR_14 (line 2)
F(1)=Hm_RI*x;
Error in fsolve_PO>@(x)fun(x,Hm_RI,at_RI,J) (line 202)
x = fsolve(@(x)fun(x,Hm_RI,at_RI,J),x0);
Error in fsolve (line 248)
fuser = feval(funfcn{3},x,varargin{:});
Error in fsolve_PO (line 202)
x = fsolve(@(x)fun(x,Hm_RI,at_RI,J),x0);
Caused by:
Failure in initial objective function evaluation. FSOLVE cannot continue.
  4 Comments
奥 刘
奥 刘 on 11 Nov 2021
@Jon Sorry I'm now away from my PC that run this matlab code, I will provide the data as soon as I get back to work. Really thanks for your help!

Sign in to comment.

Accepted Answer

Matt J
Matt J on 11 Nov 2021
Edited: Matt J on 11 Nov 2021
function F = poSTAR_14(x,Hm_RI,at_RI,J)
F1=Hm_RI*x;
F2=at_RI*x-[1;0];
F3=abs(x(1:32,1)).^2+abs(x(33:64,1)).^2-ones(J,1); %The abs() seems unnecessary here
F=[F1(:);F2(:);F3(:)];
end
  4 Comments
奥 刘
奥 刘 on 12 Nov 2021
Edited: 奥 刘 on 12 Nov 2021
After the correction, 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"?

Sign in to comment.

More Answers (0)

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!