MATLAB: Fsolve Error! Help needed

abcd to s-matrixfsolvenon-linear equations

Hi Experts,
I have designed a dual mode coupled LC resonator and written the ABCD Matrix solution for it!! Now when i pass the non linear equations for ABCD to s21 transformation through Fsolve algorithm, I get the following result using the initial guess:
guess=[42e-11 18e-13 173e-13]
guess =
1.0e-009 *
0.4200 0.0018 0.0173
>> fsolve(@double_coupled_eqns_reverse,guess)
Warning: Trust-region-dogleg algorithm of FSOLVE cannot handle non-square
systems; using Levenberg-Marquardt algorithm instead.
> In fsolve at 323
No solution found.
fsolve stopped because the problem appears to be locally singular.
<stopping criteria details>
ans =
1.0e-009 *
0.4200 0.0018 0.0173
fsolve stopped because the regularization parameter, 1.000000e+017, exceeds 1e16.
-------------------------------------------------------------------------------
function [ out ] = double_coupled_eqns_reverse( in )
Lc=in(1);
Ct=in(2);
Lc_=in(3);
out=[];
L=8e-9;
C=0.901e-12;
La=L-Lc;
La_=L-Lc_;
Lb=La;
Lb_=La_;
%%%%%%%%%%%%%%%Data From Graph %%%%%%%%%%%%%
w=2*pi*[1.846e9 1.856e9 1.866e9 1.877e9 1.886e9 1.896e9 1906e6 ];
S12_log=[-36.26 -27.76 -0.24 -18.64 -0.12 -28.11 -36.72] ;
%%%%%%%%%%%%%%%Plot Frequency %%%%%%%%%%%%%%
%%%w=2*pi*[1840e6:1e6:1940e6];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for q=1:length(w)
%%%%%%%%%%%%%%%%%%Stage1%%%%%%%%%%%%%%%%%%%%
Za(q)=1i*w(q)*La;
Zac(q)=La/Lc;
X(q)=(2*Za(q))+(Zac(q)*Za(q));
Za_(q)=1i*w(q)*La_;
Zac_(q)=La_/Lc_;
X_(q)=2*Za_(q)+Zac_(q)*Za_(q);
Zb(q)=1i*w(q)*Lb;
Zb_(q)=1i*w(q)*Lb_;
Zbc(q)=Lb/Lc;
Zbc_(q)=Lb_/Lc_;
Yc1(q)=1i*w(q)*Ct;
Yc(q)=(-1i)/(w(q)*Lc);
Yc_(q)=(-1i)/(w(q)*Lc_);
%%%%%%%%%%%%%%%%%%%%%%Stage2%%%%%%%%%%%%%%%%
Z1ac(q)=1+Zac(q);
Z1bc(q)=1+Zbc(q);
Z1ac_(q)=1+Zac_(q);
Z1bc_(q)=1+Zbc_(q);
%%%%%%%%%%%%%%%%%%%%%Stage3%%%%%%%%%%%%%%%%
A1(q)=Z1ac(q)+Yc1(q)*X(q);
A2(q)=Z1ac_(q)+Yc1(q)*X_(q);
C1(q)=Yc(q)+Yc1(q)*Z1bc(q);
C2(q)=Yc_(q)+Yc1(q)*Z1bc_(q);
%%%%%%%%%%%%%%%%%%%%%Stage4 %%%%%%%%%%%%%%%%
A1_(q)=A1(q)*A2(q)+X(q)*C2(q);
B1_(q)=A1(q)*X_(q)+X(q)*Z1bc_(q);
C1_(q)=C1(q)*A2(q)+Z1bc(q)*C2(q);
D1_(q)=C1(q)*X_(q)+Z1bc(q)*Z1bc_(q);
%%%%%%%%%%%%%%%%%%%%%Stage5 %%%%%%%%%%%%%%%%
A(q)=A1_(q)*Z1ac(q)+B1_(q)*Yc(q);
B(q)=A1_(q)*X(q)+B1_(q)*Z1bc(q);
C(q)=C1_(q)*Z1ac(q)+D1_(q)*Yc(q);
D(q)=C1_(q)*X(q)+D1_(q)*Z1bc(q);
%%%%%%%%%%%%%%%ABCD to S12 Transformation %%%%%%%%%%%%
Zo=50;
%%%S12(q)=(2*Zo)/abs(A(q)*Zo+B(q)+(C(q)*Zo^2)+D(q)*Zo);
%%%out_value(q)=20*log10(S12(q));
%%%%%%%%%%%%%%%%%%Building 3 equations %%%%%%%%%%%%%%%%
S12_lin(q)=10^(S12_log(q)/20);
magnitude(q)=abs(A(q)*Zo+B(q)+(C(q)*Zo^2)+D(q)*Zo);
out(q)=S12_lin(q)*magnitude(q)-2*Zo;
end
out=out';
%plot(w/(2*pi),out_value);
end
——————————————————————————-
What does this tell me about the health of my equations and solution? Is there anyway i can correct and verify my solution?
Best Regards,
Khawar

Best Answer

You might first try changing the units of "guess" to something such that it's typical values aren't so small, and similarly with the units of "out" if that has the same typical values.. The Optimization Toolbox functions have optimset parameters TolX and TolFun whose default values are 1e-6. This means the solvers expect things to be scaled so that changes in the parameters of on the order of 1e-6 will produce changes in "out" of around at least 1e-6 and vice versa.
Other than that, I would point out that you have more equations (7) than unknowns (3), so you're likely to get a least squares solution, as opposed to an exact solution.