필터 지우기
필터 지우기

Failure in initial objective function evaluation. FSOLVE cannot continue.

조회 수: 7 (최근 30일)
奥 刘
奥 刘 2021년 11월 11일
편집: 奥 刘 2021년 11월 12일
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
奥 刘
奥 刘 2021년 11월 11일
@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!
奥 刘
奥 刘 2021년 11월 12일
@Jon Thanks for your help! I have solved this problem.

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2021년 11월 11일
편집: Matt J 2021년 11월 11일
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
奥 刘
奥 刘 2021년 11월 12일
편집: 奥 刘 2021년 11월 12일
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"?
奥 刘
奥 刘 2021년 11월 12일
@Matt J Thanks! Now I know why I am wrong.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by