S-Parameter Plotter - Page 1
Forum section: electronics / rf-microwave

author: k6sti
author_rank: Contributor
timestamp: May 24, 2025, 06:08:47 pm
content: https://k6sti.neocities.org/splot.htmBrian

author: radiolistener
author_rank: Super Contributor
timestamp: May 26, 2025, 12:23:47 am
content: you can do it with octave, for example:Code:data = dlmread('BPF-2450BP15Q0100.s2p', '', 5, 0); % skip 5 lines in headerfreq = data(:, 1);s11 = data(:, 2) + j*data(:, 3);s21 = data(:, 4) + j*data(:, 5);freq /= 1000000; % Hz to MHzs11_dB = 20*log10(abs(s11 + eps)); % linear to dBs21_dB = 20*log10(abs(s21 + eps)); % linear to dBfigure;hold on;plot(freq, s11_dB);plot(freq, s21_dB);xlabel('MHz');ylabel('dB');xlim([min(freq) max(freq)]);ylim([min([s11_dB(:); s21_dB(:)])-10, 6.02]);grid on;grid minor;The positions of the S11 and S21 values are hardcoded in the code, but it's simpler to inspect the S2P file manually and enter the required indices directly, rather than implementing a parser to extract parameter indices by name.If needed, you can add calculations for VSWR and other parameters, as Octave provides convenient tools for a wide range of computations.

author: rf-fil
author_rank: Regular Contributor
timestamp: May 26, 2025, 12:49:50 am
content: Nice. There used to be a neat little Windows app called Iowa Hills Smith Chart that could do plotting but also allowed a simple matching circuit to be drawn up and tuned. Any plans to add something like that?

author: ftg
author_rank: Frequent Contributor
timestamp: May 26, 2025, 08:09:32 am
content: Quote from: rf-fil on May 26, 2025, 12:49:50 amIsn't this more or less what SimNEC, former SimSmith does?https://www.ae6ty.com/smith_charts/It displays the S-parameter file on the Smith chart and allows building a matching network for it.

author: k6sti
author_rank: Contributor
timestamp: May 27, 2025, 05:26:46 pm
content: Quote from: rf-fil on May 26, 2025, 12:49:50 amNo. I wrote the program mainly to provide reference impedance renormalization and the Y21 method. I think impedance matching is better done these days with nongraphical programs that can automatically optimize the match.Brian

author: radiolistener
author_rank: Super Contributor
timestamp: May 27, 2025, 08:04:26 pm
content: Quote from: k6sti on May 27, 2025, 05:26:46 pmit's more easy to do math calculations in Octave, it already has many tools for that like interpolation, etc.

author: mark03
author_rank: Frequent Contributor
timestamp: June 02, 2025, 06:05:59 pm
content: Quote from: radiolistener on May 27, 2025, 08:04:26 pmUnless someone already has the Matlab baggage in their brain (hey, a lot of us do!), I would suggestnotlearning Octave. Far better to use python instead. There's even an actively developed, RF-focused "toolkit" for python called scikit-rf. I believe it can do most of the things you're suggesting here.

author: radiolistener
author_rank: Super Contributor
timestamp: June 02, 2025, 11:59:13 pm
content: Quote from: mark03 on June 02, 2025, 06:05:59 pmI don't agree, I tried python, but its very slow and has many issues. I'm using C, C++ and C# instead. But programming language is not a replacement for Matlab/Octave. You need both. Matlab/Octave for calculations, filters/model design, plots, etc. Programming language for applied implementation of algorithms. Python is often seen as a middle ground, but it's actually a poor choice for both.For example, you can find a python script that calculates THD for a wav file. But it produces very strange and incomprehensible results, different from the Matlab/Octave implementation, and the correct result is given by Matlab/Octave, just like with other calculations - at first glance, all these python packages seem to calculate what is needed, but you can't trust them. The same for scikit-rf and other. And it is very slow. If you want a more accurate result with proper calculation and with many math tools, then your choice is Matlab/Octave.As for scripting languages, in my opinion js is better than python and js more universal and faster, because unlike python, js uses jit. js has worse support for precise math (it has extended packages, but its complicated to use them), but it is supported on any platform with browser. While for precise math you can use Matlab/Octave.In practice I just use either C or Octave, running the file directly from the Geany text editor with the Run button. I set the Run button to compile the file and run it, and it's very convenient - you just create a calc.c or calc.m ​​file, enter a couple of lines of code, press Run, and see the result. And there is no need for python at all.

author: mark03
author_rank: Frequent Contributor
timestamp: June 03, 2025, 12:15:29 am
content: Quote from: radiolistener on June 02, 2025, 11:59:13 pmWell, without getting into a programming language holy war, I will simply say that if you are comfortable doing your simulations in FORTRAN (which is essentially what Matlab/Octave is---very little difference in programming constructs, program structure, etc.), then by all means, stick with that. But there are reasons why most people have moved on to languages like python for clarity and maintainability. At some point you won't even need to deploy an argument like that: the sheer mindshare advantage of python (or its eventual replacement) will be all the reason needed to switch to it.Certainly C/C++ is best if you care about speed. But I suspect that is irrelevant for the vast majority of engineering calculation/simulation work.Python with numpy/scipy now predominates in most academic settings. Certainly the $$$ licensing costs of Matlab are part of the reason, but at some point the reasons don't matter anymore---you'll need to switch just to benefit from the larger body of tools/expertise/code.Finally, if you are worried about unvetted algorithms in packages like numpy and scipy, I hope you are using Matlab, the real thing. Because I'd trust any of the standard python packages over Octave for accuracy and correctness, any day.And that is all I'll say

author: radiolistener
author_rank: Super Contributor
timestamp: June 03, 2025, 12:20:25 am
content: For frequently used scenarios such as quick RF calculations and conversion of values ​​I used to use my calculators in C#, but now I have rewritten them in html with js and they work great on any machine. Html allows you to implement a GUI for input/output of values, graphs and even sound. For example, I wrote a small page that allows you to translate text into Morse code and back for different languages, as well as play Morse code at any selected speed.

author: radiolistener
author_rank: Super Contributor
timestamp: June 03, 2025, 12:44:17 am
content: Quote from: mark03 on June 03, 2025, 12:15:29 amMatlab and Octave are high-level interpreted languages focused on numerical computing, matrix operations, data visualization, and scientific tasks. Their syntax is similar to each other but has nothing in common with Fortran at the language level.Quote from: mark03 on June 03, 2025, 12:15:29 amI personally don't see a strong need for Python in the context of engineering calculations or simulations. Matlab/Octave handles such tasks exceptionally well, especially for matrix operations and numerical algorithms.If performance is critical or a more application-level implementation is needed, it's straightforward to write performance-critical components in C and call them from Octave using MEX interfaces. This provides a powerful and efficient workflow.In this point of view, there are few, if any, areas where Python would offer a significant advantage. Python may be helpful for those less familiar with lower-level languages, but if you're comfortable with C, the combination of Octave and C covers most scientific and engineering needs effectively.When complex object-oriented structures are required, I prefer to write in C#. While it's slightly slower than C, it offers a clean and readable OOP syntax along with strong safety features - such as bounds checking and memory management, which help avoid issues like buffer overflows or accessing freed memory. This makes development more robust without sacrificing much performance in most engineering applications.Another alternative for OOP development is Java. Its JIT compiler is amazingly fast - in many cases, performance comes very close to that of C compiler.But Python still relies on an interpreter and lacks JIT compilation, making it very slow. I also don't see compelling use cases for it, as there are more suitable alternatives for other languages available.Quote from: mark03 on June 03, 2025, 12:15:29 amGNU Octave is free and can run almost any code written for Matlab.Quote from: mark03 on June 03, 2025, 12:15:29 amI used to work with Matlab and R in the past, but nowadays I primarily use Octave. Based on my experience, Octave provides more accurate results than standard Python packages, mainly because Python libraries tend to use simplified algorithms in many cases, whereas Octave implementations are often more complete and closer to the original mathematical formulations.That said, there are indeed some differences between Octave and Matlab - for example, certain windowing functions may produce slightly different results. These differences aren't necessarily incorrect, but they can diverge from Matlab's output due to implementation details. If you want exactly the same result on Matlab and Octave using such functions, you can replace it with your own implementation and it will works exactly the same. Nonetheless, for many engineering and scientific tasks, Octave remains a reliable and precise tool.I have greater trust to Octave than to Python.In the past, I frequently used C# for filter design and graphical visualization via Direct2D for GPU-accelerated vector graphics on Windows. However, Octave now offers a very convenient Qt-based plotting backend, which I’ve complemented with a few custom wrappers to streamline usage. For example, loading a WAV file, computing its FFT, and plotting the spectrum takes just a few lines of code in Octave. Surprisingly, even a 32 million-point FFT runs very efficiently even on a Raspberry Pi, faster than FFTW.PS: and another issue with Python, is that their packages often contains malware and spyware which steal your credentials, personal data and tracking information...

author: MisterHeadache
author_rank: Regular Contributor
timestamp: June 04, 2025, 02:20:01 pm
content: FWIW, I figured out how to plot .s11 data (in real/imaginary format) in Excel and get a Smith chart. Turns out it's stupidly easy, just choose scatter plot and set both the X and Y axis ranges to -1.1 / + 1.1 (the extra tenth adds a bit of space for the outer circle). Drawing the gradient circles was much harder to figure out! In my spreadsheet I also calculate the return loss, reflection coefficient, VSWR, and impedance (scalar, real, and imaginary).I used this to visually compare multple nanoVNA .s11 files at the same scale, plus do the calcuations. Maybe this doesn't fill the need of the OP, but I thought I'd just share my experience.

author: k6sti
author_rank: Contributor
timestamp: June 12, 2025, 11:42:35 pm
content: Make one VNA measurement of a crystal filter with no matching network. Then find the best filter termination by rotating the mouse wheel to vary the renormalization impedance. This method is faster and easier than doing the same thing experimentally with solder.An animated PNG illustrating this does not animate here. The image shows the response envelope for impedance changes from 500 to 2100 ohms. The animated PNG is in this writeup:https://k6sti.neocities.org/splot.htmBrian