Failure in initial objective function evaluation. FSOLVE cannot continue.

14 visualizaciones (últimos 30 días)
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 comentarios
奥 刘
奥 刘 el 11 de Nov. de 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!
奥 刘
奥 刘 el 12 de Nov. de 2021
@Jon Thanks for your help! I have solved this problem.

Iniciar sesión para comentar.

Respuesta aceptada

Matt J
Matt J el 11 de Nov. de 2021
Editada: Matt J el 11 de Nov. de 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 comentarios
奥 刘
奥 刘 el 12 de Nov. de 2021
Editada: 奥 刘 el 12 de Nov. de 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"?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by