fsolve no solution found

1 次查看(过去 30 天)
Shan  Chu
Shan Chu 2018-5-11
Dear all, I have a system of non-linear equations that needs to be solved. I have read some articles from Matlab to improve the performance of fsolve but alas, it hasn't been successful.
Could you please help me? Thanks
P/S: the general curves of alpha and beta look actually quite right (I'm not sure about the quantity) except the fact that there is a small peak at element 570. I would expect a smooth curve there so I think it's because of the no solution found from fsolve.
The code is as follows:
close all
clear all
clc
load('Data.mat')
x0=[pi;0];
for m=1:1:length(w_vector)
w=w_vector(m);
options = optimoptions('fsolve','Display','iter','Algorithm','levenberg-marquardt','ScaleProblem','jacobian','MaxFunctionEvaluations',2000,'MaxIterations',1500,'OptimalityTolerance',1e-12,'FunctionTolerance',1e-20,'StepTolerance',1e-12);
F_med = @(x) [real(k1_l)*cosh(x(1))*cos(x(2))-imag(k1_l)*sinh(x(1))*sin(x(2))+real(k2_l)*cosh(2*x(1))*cos(2*x(2))-imag(k2_l)*sinh(2*x(1))*sin(2*x(2))+real(k3_l)*cosh(3*x(1))*cos(3*x(2))-imag(k3_l)*sinh(3*x(1))*sin(3*x(2))-(w0/w)^2+1+real(L1_l(m)/L);...
real(k1_l)*sinh(x(1))*sin(x(2))+imag(k1_l)*cosh(x(1))*cos(x(2))+real(k2_l)*sinh(2*x(1))*sin(2*x(2))+imag(k2_l)*cosh(2*x(1))*cos(2*x(2))+real(k3_l)*sinh(3*x(1))*sin(3*x(2))+imag(k3_l)*cosh(3*x(1))*cos(3*x(2))-(1/Q)*(w0/w)+imag(L1_l(m)/L)];
[x,fval] = fsolve(F_med,x0,options);
alpha(m)=x(1);
beta(m)=x(2);
x0 = [x(1);x(2)];
end
figure
hold on
plot(alpha,'r','Linewidth',3)
plot(beta,'b--','Linewidth',3)
axis tight square
grid on
set(findall(gcf,'-property','FontName'),'FontName', 'Times New Roman','fontsize',22)
  2 个评论
Walter Roberson
Walter Roberson 2018-5-11
x0 is needed for the fsolve() call, but is not defined in your code and is not part of the .mat file.
Shan  Chu
Shan Chu 2018-5-14
Hi, X0=[pi;0];
I also corrected the question

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2018-5-14
You are trying to solve a system of 2 x 1001 equations in two variables, simultaneously, because your equation is in terms of the k* variables that are 1 x 1001.
Perhaps you want to loop over corresponding k* variables.

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by