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://mp-staging.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/rfbudget-analysis.md

RF Budget Cascade Analysis

Compute cascaded performance metrics (gain, noise figure, IP3, SNR, output power) through an RF signal chain using rfbudget.

Creating an RF Budget

lna = amplifier('Gain', 15, 'NF', 2, 'OIP3', 35, 'Name', 'LNA');
bpf = rfelement('Gain', -3, 'NF', 3, 'Name', 'BPF');
mix = modulator('Gain', -6, 'NF', 10, 'OIP3', 20, ...
    'LO', 2.1e9, 'ConverterType', 'Down', 'Name', 'Mixer');
ifAmp = amplifier('Gain', 20, 'NF', 4, 'OIP3', 30, 'Name', 'IFAmp');

b = rfbudget([lna bpf mix ifAmp], 2.4e9, -30, 10e6);

Constructor: rfbudget(elements, inputFreq, availInputPower_dBm, signalBW)

Name-value form (equivalent):

b = rfbudget('Elements', [lna bpf mix ifAmp], ...
    'InputFrequency', 2.4e9, ...
    'AvailableInputPower', -30, ...
    'SignalBandwidth', 10e6);

Key Properties (Read-Only Results)

All result properties return a vector with one value per stage (cumulative through the chain):

PropertyDescriptionUnits
TransducerGainCumulative gain at each stagedB
NFCumulative noise figuredB
OIP3Cumulative output third-order interceptdBm
IIP3Cumulative input third-order interceptdBm
OIP2Cumulative output second-order interceptdBm
IIP2Cumulative input second-order interceptdBm
OutputPowerOutput power at each stagedBm
OutputFrequencyFrequency at each stage outputHz
SNRSignal-to-noise ratio at each stagedB
EIRPEffective isotropic radiated power (with rfantenna)dBm
DirectivityAntenna directivity (with rfantenna)dB

System-level results are the last element of each vector:

systemGain = b.TransducerGain(end);    % Total chain gain in dB
systemNF = b.NF(end);                  % System noise figure in dB
systemOIP3 = b.OIP3(end);             % System OIP3 in dBm
systemSNR = b.SNR(end);               % Output SNR in dB
Input Properties (Read-Write)
PropertyDescription
ElementsArray of RF element objects
InputFrequencyInput signal frequency (Hz)
AvailableInputPowerAvailable input power (dBm)
SignalBandwidthSignal bandwidth (Hz)
Solver'Friis' (default) or 'HarmonicBalance'
AutoUpdatetrue (default) -- recompute on property change

Visualization

Tabular View
show(b);               % Opens interactive GUI table -- no command-window output

Gotcha: show(b) opens a GUI table widget but produces no text in the command window. For programmatic access, use b.TransducerGain, b.NF, b.OIP3, b.OutputPower, etc.

RF Budget Analyzer App
rfBudgetAnalyzer(b);   % Launch interactive RF Budget Analyzer app with pre-loaded budget
rfBudgetAnalyzer;      % Launch empty app for manual entry
Plotting
rfplot(b, 'Pout');     % Output power per stage
rfplot(b, 'GainT');    % Transducer gain per stage
rfplot(b, 'NF');       % Noise figure per stage
rfplot(b, 'OIP3');     % OIP3 per stage
rfplot(b, 'IIP3');     % IIP3 per stage
rfplot(b, 'SNR');      % SNR per stage

Valid rfplot parameter strings: 'Pout', 'GainT', 'NF', 'OIP3', 'IIP3', 'SNR', 'Sparameters', 'OneTone', 'TwoTone'.

Note: rfplot(b) with no parameter string plots S-parameters (like rfplot(sparametersObj)). To plot budget metrics, specify a parameter string: rfplot(b, 'Pout'), rfplot(b, 'GainT'), etc.

Note: 'OneTone' and 'TwoTone' require Solver='HarmonicBalance' -- they error with "Harmonic balance solutions must be computed" if the Friis solver is active.

Polar and Smith Chart Visualization

Plot S-parameters of each cascade stage vs. frequency:

polar(b, 2, 2);        % S22 of each stage on a polar plot
smithplot(b, 1, 1);    % S11 reflection coefficient on Smith chart

Solvers

SolverUse Case
'Friis' (default)Linear cascade analysis -- fast, sufficient for most system budgets
'HarmonicBalance'Nonlinear analysis -- more accurate than Friis, matches RF Blockset Circuit Envelope simulation

HarmonicBalance accounts for compression, intermodulation, and mixer spurs that Friis ignores. Use it when accuracy matters -- the results match the highly accurate Circuit Envelope simulation in RF Blockset.

b = rfbudget(elements, 2.4e9, -30, 10e6, ...
    'Solver', 'HarmonicBalance', 'WaitBar', false);

For HarmonicBalance, control harmonic content:

b = rfbudget(elements, 2.4e9, -30, 10e6, ...
    'Solver', 'HarmonicBalance', ...
    'HarmonicOrder', 3, 'WaitBar', false);

Tip: Set 'WaitBar', false when scripting or running programmatically -- suppresses the progress bar GUI that otherwise appears during HarmonicBalance computation.

AM/PM Compression Table

Compute the system's AM/AM and AM/PM characteristic:

ampmTable = computeAMPMTable(b);
% ampmTable: M-3 matrix [Pin_dBm, Pout_dBm, PhaseShift_deg]

% With custom input power range
pinRange = -40:0.5:10;
ampmTable = computeAMPMTable(b, pinRange);

Computing System P1dB

Extract the 1-dB compression point from the AM/PM table:

b = rfbudget(elements, 2.4e9, -30, 10e6, ...
    'Solver', 'HarmonicBalance', 'WaitBar', false);

ampm = computeAMPMTable(b, -50:0.5:10);
% ampm columns: [Pin_dBm, Pout_dBm, PhaseShift_deg]

gain = ampm(:,2) - ampm(:,1);          % Realized gain vs input power
linearGain = gain(1);                   % Small-signal gain (first point)
idx = find(gain <= linearGain - 1, 1);  % First point where gain drops 1 dB
inputP1dB = ampm(idx, 1);              % System input P1dB (dBm)
outputP1dB = ampm(idx, 2);            % System output P1dB (dBm)

This is the correct way to find system P1dB -- it accounts for cascaded compression across all stages. Do not manually refer individual element P1dB values to the output; computeAMPMTable handles the full nonlinear cascade.

Mismatch Loss

ml = mismatchLoss(b, 1);     % Mismatch loss at stage 1 input boundary (per frequency)
ml = mismatchLoss(b, 2);     % Mismatch loss at stage 2 input boundary (per frequency)

Arguments: (rfbudgetObj, stageNum) -- stageNum is required (1 to number of elements). Returns a vector of linear loss factors (one per frequency point, 0 to 1, where 1 = perfect match).

AutoUpdate and Manual Computation

By default, rfbudget recomputes whenever a property changes. For batch modifications, disable auto-update:

b = rfbudget(elements, 2.4e9, -30, 10e6, 'AutoUpdate', false);
b.InputFrequency = 5.8e9;
b.AvailableInputPower = -20;
computeBudget(b);     % Explicitly trigger computation

Export

exportScript(b);              % Opens generated MATLAB script in the editor
exportRFBlockset(b);          % Opens Simulink model with RF Blockset blocks
exportReceiver(b);            % Opens receiver configuration script in the editor
exportTransmitter(b);         % Opens transmitter configuration script in the editor
c = circuit(b);               % Convert to circuit for S-parameter extraction
s = sparameters(c, freq);

Gotchas

  1. Elements cannot appear twice -- The same element object cannot be used more than once, whether in the same chain (e.g., rfbudget([lna filt lna], ...)) or across separate budgets. Use clone(element) to create an independent copy: rfbudget([lna filt clone(lna)], ...).

  2. Name must be valid MATLAB identifier -- Element Name property cannot contain spaces or special characters. Use 'IFAmp' not 'IF Amp'.

  3. Per-stage results are cumulative -- TransducerGain, NF, OIP3 etc. are cumulative through the chain, not per-element deltas. The system result is always the last element.

  4. rfplot default is S-parameters -- rfplot(b) with no parameter string plots S-parameters. Specify a string for budget metrics: rfplot(b, 'Pout'), rfplot(b, 'GainT'), etc.

  5. Frequency changes at mixers -- OutputFrequency changes after a modulator element (down/up conversion). Subsequent stages operate at the new frequency.

  6. show(b) opens GUI, no text output -- Use properties for programmatic access.

Conventions

  • Use tiledlayout/nexttile for multi-panel budget comparison plots

  • Always label plots with units (dBm, dB, GHz)

  • Use show(b) for quick inspection before plotting

  • Name elements descriptively for readable show output


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.

Download ZIP

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