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.

Request for MATLAB Code Review and Correction


Saud Aldhafyan 2026/03/17 11:28

The image contains the Transmission Line (TRL) equation. I am trying to develop a MATLAB code that matches this equation accurately. However, I need to verify that the implementation is consistent with the mathematical expression shown in the image.

Could you please review it and help ensure that the MATLAB code correctly follows the TRL equation?

Here this matlab code

clc;
clear;

% ===== Constants =====
c = 3e8; % Speed of light (m/s)
d = 2.62e-3; % Thickness in meters (example: 2.62 mm)

% ------------------- Ask user to select Excel file -------------------
[filename, pathname] = uigetfile( '*.xlsx' , 'Select your S-parameter Excel file' );
if isequal(filename,0)
error( 'No file selected. Exiting...' );
end
filepath = fullfile(pathname, filename);

% ===== Read data from Excel =====
% Make sure your Excel file has columns: frequency(Hz), e', e'', u', u''
data = readmatrix(filepath); % Reads all numeric data

f = data(:,1); % Frequency in Hz
ep_real = data(:,2); % e'
ep_imag = data(:,3); % e''
mu_real = data(:,4); % u'
mu_imag = data(:,5); % u''

% ===== Complex parameters =====
eps_r = ep_real - 1i*ep_imag;
mu_r = mu_real - 1i*mu_imag;

% ===== Input impedance calculation =====
Zin = sqrt(mu_r ./ eps_r) .* tanh(-1i .* (2*pi.*f.*d./c) .* sqrt(mu_r .* eps_r));

% ===== Reflection Loss =====
RL = 20*log10(abs((Zin - 1) ./ (Zin + 1)));

% ===== Reflection coefficient =====
Gamma = abs((Zin - 1) ./ (Zin + 1));

% ===== Absorption percentage =====
Absorption = (1 - Gamma.^2) * 100;

% ===== Display results =====
Result = table(f, RL, Absorption)

% ===== Plot RL =====
figure
plot(f/1e9, RL, 'LineWidth' ,2)
xlabel( 'Frequency (GHz)' )
ylabel( 'Reflection Loss (dB)' )
title( 'Reflection Loss vs Frequency' )
grid on

JRW 2026/03/18 20:47

Hi Saud,

1. Please post a copy of your xl/csv file. I can write a function to
evaluate those equations and plot the result to check what you have
published.

2. Can you post a picture of your plot.

3. Please provide a reference from where you obtained your 2 equations.
Attached is a picture, on transmission lines, from my record.

4. Please write your code as a MATLAB function.

Regards,

Jeremy.

On 17/03/2026 18:28, Saud Aldhafyan via groups.io wrote:

Saud Aldhafyan 2026/03/20 20:34

Dear Jeremy,

Please find the attached article


clc;
clear;
% ===== Constants =====
c = 3e8; % Speed of light (m/s)
d = 2.62e-3; % Thickness in meters (example: 2.62 mm)
% ------------------- Ask user to select Excel file -------------------
[filename, pathname] = uigetfile('*.xlsx', 'Select your S-parameter Excel
file');
if isequal(filename,0)
error('No file selected. Exiting...');
end
filepath = fullfile(pathname, filename);
% ===== Read data from Excel =====
% Make sure your Excel file has columns: frequency(Hz), e', e'', u', u''
data = readmatrix(filepath); % Reads all numeric data
f = data(:,1); % Frequency in Hz
ep_real = data(:,2); % e'
ep_imag = data(:,3); % e''
mu_real = data(:,4); % u'
mu_imag = data(:,5); % u''
% ===== Complex parameters =====
eps_r = ep_real - 1i*ep_imag;
mu_r = mu_real - 1i*mu_imag;
% ===== Input impedance calculation =====
Zin = sqrt(mu_r ./ eps_r) .* tanh(-1i .* (2*pi.*f.*d./c) .* sqrt(mu_r .*
eps_r));
% ===== Reflection Loss =====
RL = 20*log10(abs((Zin - 1) ./ (Zin + 1)));
% ===== Reflection coefficient =====
Gamma = abs((Zin - 1) ./ (Zin + 1));
% ===== Absorption percentage =====
Absorption = (1 - Gamma.^2) * 100;
% ===== Display results =====
Result = table(f, RL, Absorption)
% ===== Plot RL =====
figure
plot(f/1e9, RL,'LineWidth',2)
xlabel('Frequency (GHz)')
ylabel('Reflection Loss (dB)')
title('Reflection Loss vs Frequency')
grid on


On Fri, 20 Mar 2026 at 8:11 PM JRW via groups.io <wallerjr=
bigpond.com@groups.io> wrote:

W4JDY1953_G 2026/03/20 15:52

Right on Jeremy … these look like the basic EM 101 course book equations a second year EE student takes.

JRW 2026/03/21 09:11

OK,

1. Thanks for the article. Please note that this article is about
microwave absorbing materials.

2. I see that equations 4 and 5 were quoted.

3 . mu-r  and episilon-r were derived so no need for the csv file   ...
see equations 1 and 3 . These apply to 4mm thick thick activated carbon
samples. Are you aware that this activated carbon is used to filter boot
leg alcohol !!! ... sorry.

4. I can help with transmission lines, if needed.

73

Jeremy



On 20/03/2026 19:52, W4JDY1953_G via groups.io wrote:

Hershey 2026/03/21 03:34

Thank you so much for giving me the credit to know what your talking
about but at 85 years old that train has left the station a long time
ago.  I can't comprehend any part of your instructions altho you were
very detailed.  I appreciate your effort to provide me with a solution
to the problem.  I think my only way out is to purchase a new Nano VNA.

Thank you again for your very good reply.  Not your fault, just my
inability to follow techincal instruct9ons.

Gene Hirschman

On 3/18/26 2:47 PM, JRW via groups.io wrote:

Saud Aldhafyan 2026/03/22 16:11

Hello Jeremy


I haven’t gotten a feedback from you

On Fri, 20 Mar 2026 at 8:11 PM JRW via groups.io <wallerjr=
bigpond.com@groups.io> wrote:

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

View this thread on groups.io