Effacer les filtres
Effacer les filtres

I can't find solution with solve fuction

3 vues (au cours des 30 derniers jours)
sohyeon jung
sohyeon jung le 11 Déc 2018
Commenté : madhan ravi le 11 Déc 2018
Literally I can't find the solution with my code, which use 'solve' function to find solution of two equation.
The sol struct is filled with x(which is nowhere in my code) with this error message.
"Unable to convert expression into double array."
The code is below!
Is it because the equation itself is too complex?
How can I do for this?
S21_dB = -3.4964;
S21_deg = 2.1936;
syms er tanL positive;
assume(er, 'real');
assumeAlso(tanL, 'real');
assumeAlso(er<20 );
assumeAlso(tanL < 0.1 );
c = 3*10^8 ;
d = 731 *(10^-6);
f= 75*10^9;
lam = c./f;
w= 2*pi*f;
u_0 = 4*pi*(10^-7);
e_0 = 8.8541*(10^-12);
ec = er.*(1-1i*tanL);
z_0 = sqrt(u_0/(e_0));
z_d = sqrt(u_0/(e_0.*ec));
r = ((2*pi)/lam)*sqrt(ec);
S21_M = ((z_d+z_0).^2 - (z_d-z_0).^2)./((exp(1i.*r.*d).*(z_d+z_0).^2)- (exp(-1i*r*d).*(z_d-z_0).^2));
S21dB_M = real(20*log10(S21_M));
S21deg_M = real(angle(S21_M));
eqn1 = S21_dB- S21dB_M == 0;
eqn2 = S21_deg- S21deg_M == 0;
sol = solve([eqn1 eqn2],[er tanL],'ReturnConditions',true);
eps = double(sol.er);
losst = double(sol.tanL);
sol.er
  3 commentaires
Walter Roberson
Walter Roberson le 11 Déc 2018
you define S21_dB but you use S21dB
sohyeon jung
sohyeon jung le 11 Déc 2018
Thank you for your comment! I edited the code. But there are still some error message. Could you look into this problem again? Thank you so much!!

Connectez-vous pour commenter.

Réponse acceptée

madhan ravi
madhan ravi le 11 Déc 2018
Modifié(e) : madhan ravi le 11 Déc 2018
You are solving system of non-linear equations so use fsolve()
S21_dB = -3.4964;
S21_deg = 2.1936;
syms er tanL real;
assumeAlso(er<20 );
assumeAlso(tanL < 0.1 );
c = 3*10^8 ;
d = 731 *(10^-6);
f= 75*10^9;
lam = c./f;
w= 2*pi*f;
u_0 = 4*pi*(10^-7);
e_0 = 8.8541*(10^-12);
ec = er.*(1-1i*tanL);
z_0 = sqrt(u_0/(e_0));
z_d = sqrt(u_0/(e_0.*ec));
r = ((2*pi)/lam)*sqrt(ec);
S21_M = ((z_d+z_0).^2 - (z_d-z_0).^2)./((exp(1i.*r.*d).*(z_d+z_0).^2)- (exp(-1i*r*d).*(z_d-z_0).^2));
S21dB_M = real(20*log10(S21_M));
S21deg_M = real(angle(S21_M));
[tanL,er]=fsolve(@rootss,[10,10])
function eqn=rootss(x)
tanL=x(1);
er=x(2);
eqn=[20*real(log((((-777820666600722137088/(5480422450918343*er*(- 1 + tanL*1i)))^(1/2) - 6627542629724307/17592186044416)^2 - ((-777820666600722137088/(5480422450918343*er*(- 1 + tanL*1i)))^(1/2) + 6627542629724307/17592186044416)^2)/(exp(-(pi*(-er*(- 1 + tanL*1i))^(1/2)*842785619867605125i)/2305843009213693952)*((-777820666600722137088/(5480422450918343*er*(- 1 + tanL*1i)))^(1/2) - 6627542629724307/17592186044416)^2 - exp((pi*(-er*(- 1 + tanL*1i))^(1/2)*842785619867605125i)/2305843009213693952)*((-777820666600722137088/(5480422450918343*er*(- 1 + tanL*1i)))^(1/2) + 6627542629724307/17592186044416)^2))/log(10));
angle((((-777820666600722137088/(5480422450918343*er*(- 1 + tanL*1i)))^(1/2) - 6627542629724307/17592186044416)^2 - ((-777820666600722137088/(5480422450918343*er*(- 1 + tanL*1i)))^(1/2) + 6627542629724307/17592186044416)^2)/(exp(-(pi*(-er*(- 1 + tanL*1i))^(1/2)*842785619867605125i)/2305843009213693952)*((-777820666600722137088/(5480422450918343*er*(- 1 + tanL*1i)))^(1/2) - 6627542629724307/17592186044416)^2 - exp((pi*(-er*(- 1 + tanL*1i))^(1/2)*842785619867605125i)/2305843009213693952)*((-777820666600722137088/(5480422450918343*er*(- 1 + tanL*1i)))^(1/2) + 6627542629724307/17592186044416)^2))];
end
  4 commentaires
sohyeon jung
sohyeon jung le 11 Déc 2018
Modifié(e) : madhan ravi le 11 Déc 2018
Hello madhan, sincerely thank you for your guide. I solved the problem by using fsolve function.
The below is my solution.
S21_dB = -3.4964;
S21_deg = 2.1936;
f = 75*10^9;
x0 = [10,0];
x = fsolve(@(x) rootss(x,f,S21_dB,S21_deg),x0)
function eqn=rootss(x, f, S21_dB,S21_deg)
er = x(1);
tanL = x(2);
c = 3*10^8 ;
d = 731 *(10^-6);
lam = c./f;
w= 2*pi*f; %*10^9
u_0 = 4*pi*(10^-7);
e_0 = 8.8541*(10^-12);
ec = er.*(1-1i*tanL);
z_0 = sqrt(u_0/(e_0));
z_d = sqrt(u_0/(e_0.*ec));
r = ((2*pi)/lam)*sqrt(ec);
S21_M = ((z_d+z_0).^2 - (z_d-z_0).^2)./((exp(1i.*r.*d).*(z_d+z_0).^2)- (exp(-1i*r*d).*(z_d-z_0).^2));
S21dB_M = real(20*log10(S21_M));
S21deg_M = real(angle(S21_M));
eqn = [ S21_dB- S21dB_M
S21_deg- S21deg_M];
end
madhan ravi
madhan ravi le 11 Déc 2018
Anytime :)

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by