필터 지우기
필터 지우기

I can't find solution with solve fuction

조회 수: 3 (최근 30일)
sohyeon jung
sohyeon jung 2018년 12월 11일
댓글: madhan ravi 2018년 12월 11일
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
Walter Roberson
Walter Roberson 2018년 12월 11일
you define S21_dB but you use S21dB
sohyeon jung
sohyeon jung 2018년 12월 11일
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!!

댓글을 달려면 로그인하십시오.

채택된 답변

madhan ravi
madhan ravi 2018년 12월 11일
편집: madhan ravi 2018년 12월 11일
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
sohyeon jung
sohyeon jung 2018년 12월 11일
편집: madhan ravi 2018년 12월 11일
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 2018년 12월 11일
Anytime :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by