"fsolve stopped because the problem appears to be locally singular". How to find the solution?

19 views (last 30 days)
I have written a code to solve non-linear set of equations. The equation has four variables. The solutions for two of the variables are in order of (1e-12) while the other two have values in (0.01). Due to such huge variation in the solutions, 'fsolve' optimization algorithm' is unable to optimize the solution to correct precision and the solver is not running(iterating). I have been struggling to get the correct results but I'm not able to do so. Please help.
Attached are my matlab code files.
function F = RLCnew(x,wr,w,Z,Zo)
i = sqrt(-1);
k = 1;
clear all;
clc;
rng default;
format long;
i = sqrt(-1);
wr= 5.7e9*2*pi; %resonance frequency
w=2*pi*5.4e9; %non-resonant frequency
S11=0.23244+i*0.87757; %S11 at non-resonant frequency
S11o=0.135852; %S11 at resonant frequency
Z= 377*((1+S11)./(1-S11)); %Z at w
Zo=377*((1+S11o)./(1-S11o));%Z at wr
x0 = [0.001 1e-12 1e-12 0.001]; % initial guess
lb=[-inf -inf -inf -inf]; % lower bound
ub=[inf inf inf inf]; %upper bound
F=@(x) RLCnew(x,wr,w,Z,Zo); %F as a function of R,L,C
options = optimoptions(@fsolve,'Display','iter','MaxFunEvals',25000000, 'MaxIter',25000000,'DiffMinChange',1e-3,'TolFun',1e-18,'TolX',1e-16); % it will minimize F(1)^2 + F(2)^2 + F(3)^2
x = fsolve(F,x0,options); % solution for R,L C with residue
% wr=(2*pi)/sqrt(x(0)*x(1));
%function F
Ro = x(1)*k;
L = x(2)*k;
C = x(3)/k;
Rd=x(4);
A=real(1/Z);
B=imag(1/Z);
%equations to compute R,L anc C
F(1)=(A-real((1/(Rd+(1/i*w*C))+(1/(Ro+i*w*L)))));
F(2)=(B-imag((1/(Rd+(1/i*w*C))+(1/(Ro+i*w*L)))));
F(3)=wr-(1/sqrt(L*C));
F(4)=Zo-((L+(Ro*Rd*C))/((Ro+Rd)*C));
end
  2 Comments
Stephen23
Stephen23 on 4 Jan 2015
You did not attach any code, so it is difficult to make any comments on what you could do differently.
Matt J
Matt J on 4 Jan 2015
The code you've provided is too hard to interpret because the boundaries between different functions are not clearly shown. where does RLCnew begin and end? Where does
F=@(x) RLCnew(x,wr,w,Z,Zo);
really reside? It can't reside inside RLCnew as currently shown. This would lead to RLCnew recursively calling itself.

Sign in to comment.

Answers (1)

Matt J
Matt J on 4 Jan 2015
Edited: Matt J on 4 Jan 2015
You may have to re-express some of the variables in different units so that the objective has similar sensitivity to all variables. I.e., instead of solving a system like this
x+1e12*y-2=0
x-1e12*y =0
it is better to make the change of variables z=1e12*y and solve the system
x+z-2=0
x-z =0
FSOLVE has mechanisms for reducing sensitivity to scaling, but it's always good to give it what help you can.
  1 Comment
Bhavna
Bhavna on 4 Jan 2015
The equations can't be scaled by the same factor. If I'll scale one variable with 1e12 then other gets reduced to 1e-24. Hence I can't scale the equation with the same scaling factor as a whole. I have pasted my code. It can give a better understanding of what I'm trying to say.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!