How can I write in MATLAB?

2019-03-06 08:46发布

问题:

I solved NRW(Nicholson-Ross-Weir Conversion Method) conversion method and I found epsilonr(Er).

NRW Conversion Method

clc
clear all
% yansima_genlik= input('Genliği giriniz =')
yansima_genlik= .856;
%disp(['Genlik: ' num2str(yansima_genlik) ' dir. '])
%yansima_faz= input('Fazı giriniz =')
yansima_faz= 163.2;
%disp(['Faz açısı: ' num2str(yansima_faz) ' dir. '])


s11 = yansima_genlik*cosd(yansima_faz)+i*yansima_genlik*sind(yansima_faz);
s22 = s11;

%gecis_genlik= input('Genliği giriniz =')
gecis_genlik= .609;
%disp(['Genlik: ' num2str(gecis_genlik) ' dir. '])
%gecis_faz= input('Fazı giriniz =')
gecis_faz= -140.5;
%disp(['Faz açısı: ' num2str(gecis_faz) ' dir. '])

s21 = gecis_genlik*cosd(gecis_faz)+i*gecis_genlik*sind(gecis_faz);
s12 = s21;
f= 8*10^9;

l=0.4; %örnek uzunluğu

fc=5.26*10^9; %kesim frekansı

lamda0 = 3.75;
lamdac = 5.703;

x = (s11^2-s21^2+1)/(2*s11)

yansima1 = x + sqrt(x^2-1)
yansima2 = x - sqrt(x^2-1)

iletim = (s11+s21-yansima1)/(1-(s11+s21)*yansima1)

a = log(1/iletim) 

b = -(((1/(2*pi*l))*a)^2)

v = sqrt(1/b)

p = 1/v

Mr= (1+yansima1)/(v*(1-yansima1)*sqrt((1/lamda0)^2-(1/lamdac)^2))
%Mr=1;
Er= (lamda0^2/Mr)*(((1/lamdac)^2)+b);
Er_1= real(Er)
Er_2=imag(Er)

But my problem this pictures. I want to write "NIST Iterative Conversion Method" in MATLAB. I wrote part of the command. But I couldn't write more. Because I don't understand the algorithm.

NIST Iterative Method (Some Part)

%%%NIST Iterative Yöntemi
e0 = 8.85*10^-12;
m0 = 4*pi*10^-7;
b=3;
l1 = 1;
l2 =1;
la = l1+l2+l;

w= 2*pi*f;
isik_hizi = 1/sqrt(e0*m0);
Mr = 1;
m=m0*Mr;

y = i*sqrt((((w^2*Mr*(Er_1+i*Er_2))/isik_hizi^2)-(2*pi/lamdac)^2));
y0 = i* sqrt((w/isik_hizi)^2-(2*pi/lamdac)^2);
yansima = ((y0/m0)-(y/m))/((y0/m0)+(y/m));
T = exp(-y*l);
fx =  (s11*s22-s21*s12-(exp(-2*y0)*(la-l))*((T^2)-(yansima^2))/(1-(yansima^2*T^2))) 

Please help me. I want to write in MATLAB. But I don't know command.

回答1:

If you want find two roots you could use fslove as below:

y = @(Er) i*sqrt((((w^2*Mr*(Er))/isik_hizi^2)-(2*pi/lamdac)^2));
y0 = i* sqrt((w/isik_hizi)^2-(2*pi/lamdac)^2);
yansima = @(Er) ((y0/m0)-(y(Er)/m))/((y0/m0)+(y(Er)/m));
T = @(Er) exp(-y(Er)*l);
fx = @(Er) (s11*s22-s21*s12-(exp(-2*y0)*(la-l))*((T(Er)^2)-(yansima(Er)^2))/(1-(yansima(Er)^2*T(Er)^2)))

options = optimset(optimset('fsolve'), 'TolFun', 1.0e-12, 'TolX',1.0e-12);
Er1 = fsolve(fx, x01, options);
Er2 = fsolve(fx, x02, options);

But like i don't know the NIST method I can't help you finding x01 and x02 but in fsolve will find the closest solution to x01 (or x02) when fx(Er1) ~= 0 where Er1 is the closest solution to x01. If you want a solution close to your Er find in your first part, you can use x01 = real(Er).