Beware of cheap underperforming clones

As of 2023 there are many badly performing clones on the market. V2/3GHz NanoVNA uses parts like ADF4350 and AD8342 which are costly and clones have been cutting costs by using salvaged or reject parts.

See official store and look for V2 Plus4/V2 Plus4 Pro versions only to avoid getting a bad clone. We have stopped selling V2.2 versions since October 2020, so all V2 hardware that are not Plus or Plus4 are not made by us and we can not guarantee performance.

NanoVNA V2 Forum

Note: this page is a mirror of https://groups.io/g/NanoVNAV2.
Click here to join and see most recent posts.

Need Help Making MATLAB Code That Matches Given Permittivity and Permeability Data #clones #documentation #features #file-notice #nanovna-saver #v2


Saud Aldhafyan 2025/06/04 09:08

Hi all,

I'm working with electromagnetic materials and trying to reverse-engineer or verify complex permittivity (ε) and permeability (μ) values from S-parameter data (S11, S21). I have a dataset like this for each frequency point:

Here’s a sample of the kind of data I have (per row):

frequency(Hz), Tr1 (ε'), (ε''), Tr2 (ε'), (ε''), Tr3 (ε'), (ε''),
Tr4 (μ'), (μ''), Tr5 (μ'), (μ''), Tr6 S11(Re), (Im), Tr7 S21(Re), (Im)
8.20E+09, 2.32, -0.0456, 2.32, -0.0456, 2.32, -0.0456, 0.832, 0.0824, 0.832, 0.0824, -0.128, -0.310, 0.809, -0.456

And here is the MATLAB code I currently have:

clc; clear;
% Constants
c = 3e8;                % Speed of light (m/s)
freq_Hz = 8.20e9;       % Frequency (Hz)
d = 0.002;              % Sample thickness (m)
omega = 2*pi*freq_Hz;
% Given S-parameters from Keysight
S11 = -0.128 - 1i*0.310;
S21 = 0.809 - 1i*0.456;
% Step 1: Calculate reflection coefficient Gamma
X = (S11.^2 - S21.^2 + 1) ./ (2*S11);
root = sqrt(X.^2 - 1);
Gamma_candidates = [X + root, X - root];
Gamma = Gamma_candidates(abs(Gamma_candidates) < 1);
% Step 2: Calculate e^(-gamma*2d)
e_neg_gamma_2d = S21 ./ (1 - Gamma .* S11);
% Step 3: Phase unwrap for proper branch selection
mag = abs(e_neg_gamma_2d);
phase = unwrap(angle(e_neg_gamma_2d));
e_neg_gamma_2d_unwrapped = mag .* exp(1i*phase);
% Step 4: Calculate gamma (propagation constant)
gamma = -log(e_neg_gamma_2d_unwrapped) / (2*d);
% Step 5: Refractive index n
n = gamma * c / (1i * omega);
% Step 6: Impedance Z
Z = (1 + Gamma) ./ (1 - Gamma);
% Step 7: Relative permeability and permittivity
mu_r = n .* Z;
epsilon_r = n ./ Z;
% Step 8: Display results
fprintf('Results at %.2f GHz:\n', freq_Hz/1e9);
fprintf('Real Permittivity (ε\')   : %.6f\n', real(epsilon_r));
fprintf('Imaginary Permittivity (ε\'\') : %.6f\n', -abs(imag(epsilon_r)));
fprintf('Real Permeability (μ\')    : %.6f\n', real(mu_r));
fprintf('Imaginary Permeability (μ\'\')  : %.6f\n', -abs(imag(mu_r)));

What I’m looking for:

*

A way to *adjust or verify this code so that it gives me ε and μ matching the values in my data* (as shown above).

*

Possibly suggestions on which assumptions or approximations in NRW might need tweaking (e.g., sample thickness, sign convention, root choice, etc.).

*

Bonus: how to handle this across multiple frequencies from Excel.

Any insights or examples would really help. Let me know if you want the full dataset or script I’m using.

Thanks a lot!

Best regards,

Jim Lux 2025/06/10 14:21

I'm not sure the reflection coefficient is calculated correctly. Isn't S11 basically the reflection coefficient (in dB) - S11 is the reflected voltage divided by the incident voltage, which is the very definition of reflection coefficient.
Granted, taking typical mag/phase data you'd have to convert from dB magnitude and angle to complex, but you've already got that done in your numbers from Keysight.


Why are you subtracting S21^2, etc

Saud Aldhafyan 2025/06/10 22:20

*Hi Jim,*

Thanks for your input — you’re absolutely right that S11 represents the
reflection coefficient, and in many contexts, especially for simple
transmission lines, it can be used directly.

In this case though, I’m applying the Nicolson-Ross-Weir (NRW) method to
extract the complex permittivity and permeability of a material from
S-parameter data (S11 and S21). The method involves calculating the
internal reflection coefficient and propagation constant to back out ε and
μ, so it goes beyond treating S11 as the total reflection coefficient
alone. It also accounts for multiple internal reflections and phase shifts
through the sample thickness.

I initially thought simplifying the calculation using S11 directly might
work, but the results ended up diverging quite a bit from the reference ε
and μ values I’m trying to match.

<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Tue, Jun 10, 2025 at 6:59 PM Jim Lux via groups.io <jimlux=
earthlink.net@groups.io> wrote:

Saud Aldhafyan 2025/06/10 12:21

*Hi Jim,*

Thanks for your input — you’re absolutely right that S11 represents the reflection coefficient, and in many contexts, especially for simple transmission lines, it can be used directly.

In this case though, I’m applying the Nicolson-Ross-Weir (NRW) method to extract the complex permittivity and permeability of a material from S-parameter data (S11 and S21). The method involves calculating the internal reflection coefficient and propagation constant to back out ε and μ, so it goes beyond treating S11 as the total reflection coefficient alone. It also accounts for multiple internal reflections and phase shifts through the sample thickness.

I initially thought simplifying the calculation using S11 directly might work, but the results ended up diverging quite a bit from the reference ε and μ values I’m trying to match.

To reply to this topic, join https://groups.io/g/NanoVNAV2

View this thread on groups.io