Plotting S parameters in Matlab

Hi. So I'm trying to plot S parameters of a system. I need to plot S11 and S21 and have equations for both (derived from network synthesis data). Now my question is:
1) should I use
sparameters(S11,f)
command if the equation for S11 that I have in the code already defines it as S parameter?
S11(1,x)=1+2*i*Rs*inv(A(1,1));
A changes with frequency, and my code is designed such that every value of A(1,1) yeilds a different S11 parameter and that is stored in location (1,x) with x increasing with each cycle (x=x+1).
2) I'm not getting the right curve with or without using the sparameters command. Also rfplot and plot yield the same incorrect curve. Should S11 be in dB?

回答 (2 件)

Rishav
Rishav 2024 年 5 月 15 日

0 投票

Hi John,
The 'sparameters' command in MATLAB is typically used to create an S-parameters object from S-parameter data, usually read from a file or directly measured. If you already have an equation that defines S11 as a function of frequency and other parameters ('A' in your case), you do not need to use the 'sparameters' command to define S11.
Given your explanation, it seems you are already calculating S11 correctly across different frequencies. The key is to ensure that A(1,1) changes with frequency as intended and that you correctly iterate over 'x' to store each computed S11 value.
If the curve you are getting is not correct, please check the following pointers:
  • Frequency Range and Step: Ensure that the frequency range and step size are correctly defined. Plotting over a very narrow range or using an incorrect step size can lead to misleading results.
  • Equation Accuracy: Double-check the equation for S11 to ensure it is correctly implemented in your code. A small error in the equation or its implementation can lead to significant discrepancies in the plot.
  • Plotting in dB: To convert S11 to dB, you can use the formula 20*log10(|S11|). If S11 is complex, ensure to use the magnitude of S11 in the conversion:
S11_dB = 20*log10(abs(S11));
Then, plot 'S11_dB' against your frequency range.
  • Plotting Method: If 'rfplot' and 'plot' yield the same incorrect curve, the issue likely lies in the data being plotted, not the plotting function itself. Ensure that the data passed to these functions is correct.
Mark
Mark 約3時間 前

0 投票

The data going into sparameters() must be complex linear (not dB), and the S-matrix must be a 3D array of size NxNxM where M is the number of frequency points. The row vector S11(1,x) needs reshaping, and your formula might have a units/conversion error.
Correct Use of sparameters with Computed Data
The constructor signature is:
s = sparameters(Sdata, freq, Z0)
where Sdata is N x N x numFreqs. For a one-port system:
% If S11 is a 1 x numFreqs row vector of complex values:
Sdata = reshape(S11, 1, 1, []); % becomes 1x1xnumFreqs
freq = ... ; % frequency vector in Hz
s = sparameters(Sdata, freq, 50); % 50-ohm reference
For a two-port where you have both S11 and S21:
numFreqs = numel(freq);
Sdata = zeros(2, 2, numFreqs);
Sdata(1,1,:) = S11_vec; % complex, linear
Sdata(2,1,:) = S21_vec; % complex, linear
% S12, S22 set to 0 or computed values as needed
s = sparameters(Sdata, freq, 50);
The Formula Looks Suspicious
S11(1,x) = 1 + 2*i*Rs*inv(A(1,1));
This doesn't match any standard S-parameter definition. For a one-port impedance Z:
S11 = (Z - Z0) / (Z + Z0
Your formula produces values with real part starting at 1, which means |S11| > 1 — non-physical for a passive network. You could check:
  • Is A an ABCD matrix? If so, the correct conversion from ABCD to S11 (for a two-port terminated in Z0) is:
S11 = (A + B/Z0 - C*Z0 - D) / (A + B/Z0 + C*Z0 + D)
  • Is this a Z-parameter you haven't converted yet? If Z_in = Rs + some_function(A), then: S11 = (Z_in - Z0) ./ (Z_in + Z0);
This is almost certainly why the curve is wrong — the formula itself, not the plotting.
Should S11 Be in dB?
No — data stored in sparameters objects is always complex linear. The plotting functions handle conversion:
  • rfplot(s) — automatically plots in dB (calls 20*log10(abs(...)) internally)
  • plot(freq, S11) — plots whatever you give it, so for dB you'd need:
plot(freq/1e9, 20*log10(abs(S11_vec)))
xlabel('Frequency (GHz)')
ylabel('|S_{11}| (dB)')
If you pass dB values into sparameters(), then rfplot applies 20*log10 again, giving nonsensical results.
Suggested Diagnostic
% After computing S11 vector, sanity-check:
figure;
tiledlayout(1,2)
nexttile
plot(freq/1e9, abs(S11_vec))
ylabel('|S_{11}| (linear)')
xlabel('Frequency (GHz)')
yline(1, 'r--', '|S11|=1 (passive limit)')
title('Magnitude check')
nexttile
plot(freq/1e9, 20*log10(abs(S11_vec)))
ylabel('|S_{11}| (dB)')
xlabel('Frequency (GHz)')
yline(0, 'r--', '0 dB (passive limit)')
title('dB check')
If the magnitude exceeds 1 (or 0 dB), your formula is wrong — it's computing something other than a reflection coefficient.
Summary
(1) Reshape to 3D before passing to sparameters
(2) The real problem is almost certainly the 1 + 2i*Rs*inv(A) formula — that's not a valid S-parameter conversion. You should verify what A represents and use the correct conversion
(3) Always store complex linear values; rfplot handles dB conversion automatically.

カテゴリ

ヘルプ センター および File ExchangeRF Toolbox についてさらに検索

製品

質問済み:

2021 年 3 月 6 日

回答済み:

約3時間 前

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by