fsolve no solution found
1 回表示 (過去 30 日間)
古いコメントを表示
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
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.
回答 (1 件)
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Systems of Nonlinear Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!