fsolve no solution found
1 view (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 11 May 2018
x0 is needed for the fsolve() call, but is not defined in your code and is not part of the .mat file.
Answers (1)
Walter Roberson
on 14 May 2018
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 Comments
See Also
Categories
Find more on Systems of Nonlinear Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!