Saud Aldhafyan 2025/06/08 02:58

I am using the NRW method in MATLAB to calculate the real and imaginary parts of permittivity (ε′, ε″) and permeability (μ′, μ″) from S-parameters measured in a waveguide at 8.2 GHz with a 2 mm thick sample. My goal is to obtain results close to the expected values:

* ε′ ≈ 2.32
* ε″ ≈ -0.0456
* μ′ ≈ 0.832
* μ″ ≈ 0.0824

How can I modify or verify my MATLAB code to ensure it produces these values accurately from the given S11 and S21 data?

% Constants
c = 3e8;
mu0 = 4*pi*1e-7;
eps0 = 8.854e-12;
a = 22.86e-3;
d = 2e-3;
f = 8.2e9;

% Waveguide parameters
k0 = 2*pi*f/c;
fc = c/(2*a);
kc = pi/a;
gamma0 = 1i * sqrt(k0^2 - kc^2);

% Given S-parameters
S11 = -0.1278677 - 1i*0.3101051;
S21 = 0.8092633 - 1i*0.4556378;

% Calculate reflection coefficient R
V1 = (S11^2 - S21^2 + 1) / (2*S11);
R1 = V1 + sqrt(V1^2 - 1);
R2 = V1 - sqrt(V1^2 - 1);
if abs(R2) < abs(R1)
R = R2;
else
R = R1;
end

% Calculate transmission coefficient T
T = (S11 + S21 - R) / (1 - (S11 + S21)*R);

% Calculate complex propagation constant gamma
gamma = -log(T) / d;

% Calculate impedance Z
Z = sqrt((1 + R)/(1 - R));

% Calculate relative permeability mu_r
mu_r = (Z * gamma) / gamma0;

% Calculate relative permittivity epsilon_r
epsilon_r = gamma / (1i * 2 * pi * f * sqrt(mu0 * eps0) * sqrt(mu_r));

% Display results
fprintf('epsilon_real = %.4e\n', real(epsilon_r));
fprintf('epsilon_imag = %.4e\n', imag(epsilon_r));
fprintf('mu_real = %.4e\n', real(mu_r));
fprintf('mu_imag = %.4e\n', imag(mu_r));