Generated banner for Matlab Model Rf
Generated logo for Matlab Model Rf

Matlab Model Rf

MathWorksOfficialCreated by MathWorks

  • Skill
  • Guidelines
  • Science and research
  • BSD-2-Clause
  • No issues found

From the author

RF Toolbox and RF Blockset in MATLAB -- S-parameter I/O, network conversions (S/Z/Y/ABCD/T/H/G, mixed-mode), cascade/de-embedding, rfbudget analysis, circuit composition, matching networks, amplifier stability, mixer spurs, rational fitting, SI channels, baseband processing, Circuit Envelope simulation. Trigger: sparameters, Touchstone, .s2p, .s4p, rfplot, smithplot, rfparam, rfwrite, zparameters, yparameters, abcdparameters, s2sdd, cascadesparams, deembedsparams, rfbudget, noise figure, OIP3, IIP3, amplifier, modulator, nport, rffilter, attenuator, seriesRLC, shuntRLC, lcladder, txline, circuit, setports, clone, matchingnetwork, stabilityk, stabilitymu, powergain, gammams, gammaml, mixerIMT, OpenIF, rational, rationalfit, stepresp, txlineWRLGC, rf.Amplifier, rf.Mixer, rf.Filter, rf.Sparameter, rfsystem, RF Blockset.
— the description by MathWorks

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a structured approach to utilizing MATLAB's RF Toolbox and RF Blockset for end-to-end RF system development. It covers workflows ranging from measured S-parameter data validation and network conversions to complex circuit-level design, amplifier stability analysis, and time-domain Circuit Envelope simulation. The documentation emphasizes best practices for script-based workflows, proper element handling, and avoiding common pitfalls in RF parameter manipulation and system modeling.

What it does

  • Validates and processes measured S-parameter data from Touchstone files.
  • Performs network parameter conversions and mixed-mode analysis.
  • Enables RF signal chain design and cascaded budget analysis.
  • Supports circuit-level composition and impedance matching network design.
  • Facilitates amplifier stability analysis and mixer intermodulation planning.
  • Provides tools for rational fitting and time-domain system simulation.

When to use it

  • When working with measured S-parameter data for validation or de-embedding.
  • When designing RF signal chains and performing cascaded budget analysis.
  • When composing arbitrary RF circuits using node-based netlists.
  • When analyzing amplifier stability or mixer spur performance.
  • When performing time-domain signal integrity or Circuit Envelope simulations.

Advantages

  • Unified workflow for both passive and active RF device characterization.
  • Strict adherence to MATLAB identifier and object handling rules prevents silent errors.
  • Comprehensive support for modern visualization tools like tiledlayout and smithplot.
  • Clear separation between script-based design workflows and interactive analysis.
  • Detailed guidance on avoiding common errors in port ordering and parameter units.

Usage examples

“How do I load an S-parameter file and plot it on a Smith chart?”
The agent will guide you to use sparameters() to load the file, followed by smithplot() for visualization, ensuring you handle reference impedance correctly via newref() if needed.
“Calculate the cascaded gain and noise figure for my RF chain.”
The agent will help you define elements using rfbudget, ensuring you set the SignalBandwidth and use clone() for reused elements, then run the budget analysis.
“How do I analyze the stability of an amplifier?”
The agent will instruct you to use stabilityk and stabilitymu, and calculate power gain using powergain with the correct linear-to-dB conversion.
“I need to export my S-parameters to a new file.”
The agent will provide the rfwrite command, specifically reminding you to include 'ForceOverwrite', true to avoid interactive dialogs.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/matlab/matlab-model-rf/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip matlab-model-rf.zip -d .agents/skills

Documentation by MathWorks

RF Toolbox and RF Blockset

Design, analyze, and simulate RF systems in MATLAB -- from measured S-parameter data through full time-domain Circuit Envelope simulation. One unified workflow covering passive networks, active device characterization, system cascade budgets, and behavioral time-domain modeling.

When to Use

Measured data workflows

  • Loading Touchstone files (.s1p through .snp), validating quality (passivity, causality, IEEE P370)

  • Plotting on Smith charts and rectangular plots, interpolating, re-referencing impedance

  • Converting between S, Z, Y, ABCD, T, H, G parameters; computing mixed-mode differential

  • Cascading and de-embedding S-parameter networks; fixture removal

System design and analysis

  • Building RF signal chains from behavioral elements (amplifier, modulator, rffilter, nport, etc.)

  • Computing cascaded gain, noise figure, IP3, SNR, output power with rfbudget

  • Comparing Friis vs Harmonic Balance solver accuracy

  • Exporting to RF Blockset Simulink models, Communications Toolbox, or MATLAB scripts

Circuit-level design

  • Composing arbitrary RF circuits with node wiring (SPICE-like netlist)

  • Designing impedance matching networks (L, Pi, Tee topologies, Richards stubs)

  • Analyzing amplifier stability (K-factor, mu), power gain, and matching conditions

  • Mixer intermodulation analysis and spur-free IF frequency planning

Time-domain and signal integrity

  • Fitting S-parameters to rational models; computing TDR, impulse, step responses

  • Exporting broadband circuit models to SPICE or Verilog-A

  • Building SI channel models from nport blocks, lossy transmission lines, and parasitics

  • Processing complex baseband signals through rf.Amplifier, rf.Mixer, rf.Filter System Objects

  • Full Circuit Envelope time-domain simulation via rfsystem (no Simulink knowledge required)

When NOT to Use

  • Antenna design and radiation patterns -- use Antenna Toolbox

  • RF propagation modeling (path loss, fading, ray tracing) -- use Communications Toolbox or Phased Array System Toolbox

  • SerDes/high-speed serial link equalization (FFE, CTLE, DFE, IBIS-AMI) -- use SerDes Toolbox

  • Radar waveform design or phased arrays -- use Phased Array System Toolbox

Must-Follow Rules

These apply across ALL RF Toolbox workflows. Violating them produces silent errors or blocks execution.

Universal
  1. rfwrite blocks on existing files -- Always pass 'ForceOverwrite', true. Without it, MATLAB opens an interactive overwrite dialog that halts unattended execution.

  2. Elements cannot be reused -- The same element object cannot appear twice in an rfbudget or circuit. Use clone(element) for independent copies.

  3. Element Name must be a valid MATLAB identifier -- No spaces, no special characters. Use 'IFAmp' not 'IF Amp'.

  4. Use tiledlayout/nexttile -- Not subplot. For all multi-panel figures.

  5. rfparam returns complex, not dB -- Always use 20*log10(abs(rfparam(...))) for dB magnitude.

S-Parameters and Network Parameters
  1. sparameters(filename, Z0) is invalid -- Cannot pass reference impedance at load time. Load first, then newref(s, Z0).

  2. rfinterp1 interpolates real/imag independently -- Not magnitude and angle. Can produce artifacts near sharp resonances.

  3. Frequency alignment required for cascade/de-embed -- cascadesparams and deembedsparams require identical frequency vectors. Always rfinterp1 to a common grid first.

  4. deembedsparams always requires 3 arguments -- (sMeasured, sFixture1, sFixture2). For one-sided, pass an ideal thru for the unused side.

  5. Mixed-mode port ordering is the #1 error source -- s2sdd option 1 (default) treats ports 1,2 as positive and 3,4 as negative. Verify which option matches your VNA port numbering.

  6. snp2smp argument order: ports before impedance -- snp2smp(s, portList, Z0), not snp2smp(s, Z0, portList).

rfbudget and Elements
  1. SignalBandwidth is required -- The 4th positional arg to rfbudget. Without it, NF/IP3/SNR remain empty.

  2. Passive NF equals loss -- For rfelement, NF should equal abs(Gain). Prefer attenuator which handles this automatically.

  3. nport Name is positional -- nport('file.s2p', 'MyName'), not name-value syntax.

  4. rffilter: ResponseType is shape, FilterType is algorithm -- rffilter('FilterType', 'Bandpass') errors. Use rffilter('ResponseType', 'Bandpass').

  5. show(b) opens a GUI -- Produces no command-window output. Use properties (b.TransducerGain, b.NF) for programmatic access.

Circuit Composition
  1. setports/setterminals can only be called once -- Plan topology before defining terminals.

  2. 2-port RF elements use 4-node mapping -- add(ckt, [in out inRef outRef], elem) for amplifier, modulator, nport, all txline types. Primitive 2-terminal elements (resistor, capacitor, inductor) use 2-node mapping.

  3. Primitive constructors are positional -- resistor(100, 'R1'), not resistor('Resistance', 100).

  4. setterminals takes a node vector -- setterminals(ckt, [1 2]), not setterminals(ckt, 1, 2).

  5. All txline constructors use name-value pairs only -- No positional arguments.

Amplifier Analysis
  1. powergain gain type string must be last -- powergain(s, 50, 50, 'Gt'), not powergain(s, 'Gt', 50, 50).

  2. powergain returns linear, not dB -- Convert with 10*log10(g) (power gain uses 10x, not 20x).

  3. Gmag returns NaN when conditionally stable -- Use Gmsg at frequencies where K < 1.

Rational Fitting
  1. rational vs rationalfit -- Use rational for new code (AAA). Use rationalfit only for delay extraction.

  2. Single-param fit returns plain vectors; multi-port returns cell arrays -- Always check with iscell(result).

  3. freqresp takes Hz -- Not rad/s. Pass s.Frequencies directly.

System Objects (rf.*)
  1. rf.Amplifier/rf.Mixer use 1-ohm power -- Vin = sqrt(Pin_W). This differs from rfsystem which uses 50-ohm.

  2. rf.Filter frequencies are ABSOLUTE RF -- PassFreq_bp=[2.395e9 2.405e9] means absolute GHz. Not baseband offsets.

  3. Properties locked during use -- Call release(obj) before modifying Nontunable properties.

rfsystem
  1. Requires rfbudget -- rfsystem takes an rfbudget, not raw elements.

  2. close_system needs save flag -- Use close_system(rfs, 0) to discard changes.

  3. IdealizedBaseband only supports amplifier/modulator/rffilter/nport -- Other elements require CircuitEnvelope.

Workflow Quick Reference

TaskEntry PointDetails
Load/plot S-parameterssparameters, rfplot, smithplotreference/sparameters-io.md
Convert S/Z/Y/ABCD, mixed-modezparameters, s2sdd, snp2smpreference/network-conversions.md
Cascade or de-embed networkscascadesparams, deembedsparamsreference/cascade-deembed.md
Create rfbudget elementsamplifier, modulator, rffilter, etc.reference/rfbudget-elements.md
Run cascade budget analysisrfbudget, rfplot(b, 'Pout')reference/rfbudget-analysis.md
Compose RF circuitscircuit, add, setportsreference/circuit-composition.md
Design matching networksmatchingnetwork, richardsreference/matching-networks.md
Analyze amplifier stability/gainstabilityk, powergain, gammamsreference/amplifier-analysis.md
Mixer spurs and IF planningmixerIMT, OpenIFreference/mixer-analysis.md
Fit rational models, TDRrational, stepresp, generateSPICEreference/rational-fitting.md
Build SI channel modelsnport + txlineWRLGC + circuitreference/si-channel-modeling.md
Process complex basebandrf.Amplifier, rf.Mixer, rf.Filterreference/baseband-processing.md
Time-domain system simulationrfsystem, Circuit Envelopereference/system-simulation.md

Conventions

Code Style
  • Use tiledlayout/nexttile for multi-panel figures (not subplot)

  • Always label axes with units (GHz, dB, ns, dBm) and include figure titles

  • Name elements descriptively for readable topology ('LNA', 'DCBlock', 'PCBTrace')

  • Use clone() liberally for element reuse

Script-First Workflow

For design, analysis, or sweep tasks -- write code to .m files on disk, not inline snippets. For quick one-off checks, inline evaluate_matlab_code is fine.

Modern APIs
  • tiledlayout/nexttile instead of subplot

  • datetime instead of datenum

  • rational instead of rationalfit (unless delay extraction needed)

  • smithplot instead of smith

  • rfplot for S-parameter visualization (handles dB conversion automatically)

References

Load the relevant reference file before writing code for a specific workflow. Each reference contains correct calling conventions, constructor arguments, property names, gotchas, and executable code patterns.


Copyright 2026 The MathWorks, Inc.


Files

reference/network-conversions.md

Network Parameter Conversions

Convert between S, Z, Y, ABCD, T, H, and G parameter representations. Compute mixed-mode (differential/common) S-parameters and reduce or reorder ports.

Object-Based Conversions (Preferred)

Object constructors automatically handle impedance bookkeeping. This is the modern approach.

z = zparameters(s);                    % S -> Z
y = yparameters(s);                    % S -> Y
a = abcdparameters(s);                 % S -> ABCD
t = tparameters(s);                    % S -> T (transfer/chain scattering)
h = hparameters(s);                    % S -> H (2-port only)
g = gparameters(s);                    % S -> G (2-port only)

% Convert back
sRoundTrip = sparameters(z);           % Z -> S (uses z.Impedance)
sCustomZ0 = sparameters(y, 75);        % Y -> S with 75 Ohm reference

All parameter objects share the same interface: .Parameters, .Frequencies, .Impedance, .NumPorts.

Port Count Limitations
Parameter typePort requirement
S, Y, ZN-port (any size)
ABCD, T2N-port only
H, G2-port only

Array-Based Conversions

Use when you need raw numeric arrays without object overhead.

yData = s2y(s.Parameters, s.Impedance);
zData = s2z(s.Parameters, s.Impedance);
abcdData = s2abcd(s.Parameters, s.Impedance);
tData = s2t(s.Parameters);             % No Z0 needed for T-parameters

Mixed-Mode (Differential/Common) S-Parameters

Convert 2N-port single-ended to N-port differential or common mode. Critical for high-speed serial link analysis.

s4 = sparameters('connector.s4p');

% Differential mode (Sdd)
sdd = s2sdd(s4.Parameters);            % Default: option 1 port pairing

% Common mode (Scc)
scc = s2scc(s4.Parameters);

% Cross-mode (differential-to-common and vice versa)
sdc = s2sdc(s4.Parameters);
scd = s2scd(s4.Parameters);
Port Ordering Options -- The #1 Source of Mixed-Mode Errors

For a 4-port network, the option selects which physical ports form each differential pair:

OptionDifferential Pairs (4-port)Description
1 (default)(1+,3-) and (2+,4-)First half = positive terminals, second half = negative
2(1+,2-) and (3+,4-)Adjacent ports form each pair
3(1+,2-) and (4+,3-)Pair 1 ascending, pair 2 descending
sdd_opt2 = s2sdd(s4.Parameters, 2);   % Option 2 port ordering

Gotcha: Option 1 (default) treats ports 1,2 as positive terminals and 3,4 as negative -- NOT adjacent pairing. Verify which option matches your VNA port numbering before converting. Wrong port ordering produces subtly incorrect results that look plausible but are wrong.

Gotcha: Differential impedance = 2 x single-ended impedance. When wrapping s2sdd output in a sparameters object, double the reference impedance:

sdd = s2sdd(s4.Parameters);
sDiff = sparameters(sdd, s4.Frequencies, 2*s4.Impedance);  % 100 Ohm for 50 Ohm single-ended

Port Reduction and Reordering: snp2smp

Reduce N-port to M-port by selecting ports and terminating the rest.

Gotcha: Argument order is snp2smp(s, portList, Z0) -- the port list comes before the termination impedance. Swapping them (e.g., snp2smp(s, 50, [1 3])) treats the scalar as a port index and errors.

% Extract ports 1 and 3 from a 4-port, terminate ports 2 and 4 with 50 Ohm
s2 = snp2smp(s4, [1 3], 50);

% Swap ports of a 2-port
sSwapped = snp2smp(s, [2 1]);

% Terminate with different impedances per port
s2 = snp2smp(s4, [1 3], {50, 75, 50, 75});

Transfer Function

tf = s2tf(s);                          % Voltage transfer function (option 1, default)
tf = s2tf(s, 60, 75, 2);              % Zs=60, Zl=75, option 2: Vl/Vs

Options: 1 = Vl/Va (default), 2 = Vl/Vs, 3 = power-wave gain.

Common Applications of ABCD Parameters

Propagation Constant from Transmission Line S-Parameters

For a matched transmission line of length L, the ABCD A-parameter relates to propagation constant:

s = sparameters('line.s2p');
abcd = abcdparameters(s);
A = rfparam(abcd, 1, 1);              % A-parameter vs frequency
L = 0.1;                               % Line length in meters
gamma = acosh(A) / L;                   % Complex propagation constant
alpha = real(gamma);                    % Attenuation (Np/m)
beta = unwrap(imag(gamma));             % Phase constant (rad/m), unwrapped
Loss Tangent Extraction

Extract dielectric loss tangent from the attenuation constant:

% After computing alpha from ABCD (above):
c = 3e8;
epsR = 4.4;                            % Known substrate permittivity
freq = abcd.Frequencies;
tanDelta = (alpha * c) ./ (pi * freq * sqrt(epsR));

Note: This formula assumes dielectric loss dominates. For conductor+dielectric loss separation, fit alpha = a1sqrt(f) + a2f and extract tanDelta from the a2*f (dielectric) term.

PI-Model Extraction from ABCD

Extract lumped PI-equivalent (shunt-series-shunt) from connector/short-line ABCD:

abcd = abcdparameters(s);
A = rfparam(abcd, 1, 1);
B = rfparam(abcd, 1, 2);
D = rfparam(abcd, 2, 2);

% PI-model elements at each frequency:
Zseries = B;                           % Series impedance
Y1 = (A - 1) ./ B;                    % Input shunt admittance
Y2 = (D - 1) ./ B;                    % Output shunt admittance

% Convert to lumped values at a single frequency:
f0 = freq(idx);  w0 = 2*pi*f0;
Lseries = imag(Zseries(idx)) / w0;    % Series inductance
Rseries = real(Zseries(idx));          % Series resistance
C1 = imag(Y1(idx)) / w0;              % Input shunt capacitance
C2 = imag(Y2(idx)) / w0;              % Output shunt capacitance

Synthetic Data Recipes

Use these one-shot patterns to create test data for conversion demos. Avoids iteration on data construction.

2-Port Channel (for S->Z, S->Y, S->ABCD demos)
freq = linspace(1e9, 10e9, 101).';
loss = 10.^(-0.3*freq/10e9/20);       % 0.3 dB loss at 10 GHz
phase = exp(-1j*2*pi*freq*0.5e-9);    % 0.5 ns delay
S21 = loss .* phase;
S11 = 0.05 * ones(size(freq));
sData = reshape([S11, S21, S21, S11].', 2, 2, []);
s = sparameters(sData, freq, 50);
Z-Parameter Data (for Z->S conversion demos)
freq = linspace(1e9, 5e9, 51).';
w = 2*pi*freq;
Z11 = 50 + 1j*w*2e-9;                 % 50 Ohm + 2 nH
Z22 = 75 + 1j*w*1.5e-9;              % 75 Ohm + 1.5 nH
Z12 = 1j*w*0.5e-9;                    % 0.5 nH mutual
zData = reshape([Z11, Z12, Z12, Z22].', 2, 2, []);
z = zparameters(zData, freq);          % Ready for sparameters(z, Z0)
4-Port Balanced Structure (for mixed-mode demos)

Builds a symmetric reciprocal 4-port with prescribed Sdd21 and Scc21 (option 1 pairing):

freq = linspace(1e9, 10e9, 51).';
dd21 = 0.9*exp(-1j*2*pi*freq*1e-9);   % Strong differential transmission
cc21 = 0.05*ones(size(freq));           % -26 dB common-mode transmission
dd11 = 0.1*ones(size(freq));            % Low differential reflection
cc11 = 0.1*ones(size(freq));            % Low common-mode reflection
% Compose single-ended S from modal targets (option 1: pairs 1+3-, 2+4-)
S11 = reshape((dd11+cc11)/2, 1, 1, []);
S13 = reshape((cc11-dd11)/2, 1, 1, []);
S21 = reshape((dd21+cc21)/2, 1, 1, []);
S23 = reshape((cc21-dd21)/2, 1, 1, []);
sData = [S11, S21, S13, S23;
         S21, S11, S23, S13;
         S13, S23, S11, S21;
         S23, S13, S21, S11];
s4 = sparameters(sData, freq, 50);
Quick Circuit S-Parameters (for conversion demos needing a DUT)
% L-section matching network (series L + shunt C)
ckt = circuit('LMatch');
add(ckt, [1 2], inductor(10e-9));
add(ckt, [2 3], capacitor(2e-12));
setports(ckt, [1 3], [2 3]);
freq = linspace(1e9, 3e9, 101).';
s = sparameters(ckt, freq);

% Bandpass filter (alternative one-liner)
filt = rffilter(ResponseType='Bandpass', FilterOrder=5, ...
    PassbandFrequency=[1.8e9 2.2e9]);
s = sparameters(filt, freq);
Visualizing Impedance on Smith Chart
s = sparameters(...);                  % Your S-parameter data
z = zparameters(s);
Z11 = rfparam(z, 1, 1);
gamma11 = (Z11 - s.Impedance) ./ (Z11 + s.Impedance);
smithplot();                           % Empty chart with grid
hold on;
plot(real(gamma11), imag(gamma11), 'b-', 'LineWidth', 2);
plot(real(gamma11(1)), imag(gamma11(1)), 'go', 'MarkerSize', 10);
plot(real(gamma11(end)), imag(gamma11(end)), 'rx', 'MarkerSize', 10);
title('Input Impedance Trajectory');

Round-Trip Validation

Always verify round-trip accuracy when conversion fidelity matters:

z = zparameters(s);
sBack = sparameters(z);
err = max(abs(s.Parameters(:) - sBack.Parameters(:)));
assert(err < 1e-12, 'Round-trip error: %.2e', err);

Gotchas

  1. H and G parameters are 2-port only -- hparameters(s) and gparameters(s) error for networks with more than 2 ports. ABCD and T require 2N-port (even number).

  2. Mixed-mode port ordering is the #1 error source -- s2sdd, s2scc, s2sdc, s2scd accept an option argument (1, 2, or 3) for port pairing. Verify which option matches your VNA port numbering before converting -- wrong ordering produces subtly incorrect results that look plausible.

  3. Differential impedance = 2x single-ended -- If single-ended Z0 is 50 Ohm, differential Z0 is 100 Ohm.

  4. snp2smp argument order: ports before impedance -- snp2smp(s, portList, Z0), not snp2smp(s, Z0, portList). Swapping them treats the scalar as a port index and errors.

Conventions

  • Prefer object-based conversions over array-based -- they track impedance automatically

  • Always verify round-trip accuracy (S->Z->S) when conversion fidelity matters

  • Use rfparam to extract individual parameters from any network parameter object


Copyright 2026 The MathWorks, Inc.


Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs Node.js

Security

No issues found by our static scan· No issues found

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
MathWorks
Publisher
MathWorks (Official)
Source
matlab/matlab-agentic-toolkit · skills-catalog/rf-and-mixed-signal/matlab-model-rf · commit 2a7f215
Licence
BSD 2-Clause License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE.md)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by MathWorks or MathWorks.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download matlab-model-rf.zip