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/mixer-analysis.md

Mixer Intermodulation Analysis

Analyze mixer spurious products using the mixerIMT object. Build intermodulation tables, visualize spur charts, and integrate with rfbudget for cascade analysis.

mixerIMT vs modulator

Both model frequency converters, but serve different purposes:

FeaturemodulatormixerIMT
Gain specificationGain property (direct)NominalOutputPower - ReferenceInputPower
NonlinearityOIP3-based (poly model)IMT table (arbitrary spur levels)
Spur visualizationNoYes — rfplot(m, fRF)
Constructor accepts GainYesNo — settable after construction but ignored by rfbudget
Use caseSystem-level cascade budgetsSpur analysis and frequency planning

Use modulator for quick cascade budgets. Use mixerIMT when you need to model specific spurious products or visualize spur charts.

Creating a mixerIMT

m = mixerIMT('LO', 2.1e9, 'ConverterType', 'Down', 'NF', 10, 'Name', 'Mixer');
Constructor Parameters
ParameterDefaultDescription
LO1e8Local oscillator frequency (Hz)
ConverterType'Up''Down' or 'Up' conversion — must set explicitly for down-conversion
NF0Noise figure (dB)
ReferenceInputPower-15Reference input power (dBm)
NominalOutputPower-5Nominal output power (dBm)
Modelauto'mod' (up) or 'demod' (down) — set automatically from ConverterType
Zin50Input impedance (Ohm)
Zout50Output impedance (Ohm)
IMT3x3 defaultIntermodulation table
Name'MixerIMT'Element name
Post-Construction Properties

These properties are read-write but cannot be passed to the constructor:

m.OIP3 = 20;       % Output IP3 (dBm)
m.OIP2 = 40;       % Output IP2 (dBm)

Do not set m.Gain manually. Although Gain is a settable property, rfbudget ignores it — the budget gain is determined entirely by NominalOutputPower and ReferenceInputPower. Setting m.Gain has no effect on cascade results and can be misleading.

Conversion Gain

Conversion gain in rfbudget is determined by NominalOutputPower and ReferenceInputPower. Although Gain is a settable property, rfbudget ignores it and computes gain from NominalOutputPower - ReferenceInputPower. Do not set m.Gain manually.

Budget gain = NominalOutputPower - ReferenceInputPower
% This gives 10 dB conversion gain in rfbudget:
m = mixerIMT('ReferenceInputPower', -15, 'NominalOutputPower', -5, ...
    'LO', 2.1e9, 'ConverterType', 'Down', 'Name', 'Mixer');
% Budget sees: -5 - (-15) = 10 dB

% To get -6 dB conversion loss in rfbudget:
m2 = mixerIMT('ReferenceInputPower', -10, 'NominalOutputPower', -16, ...
    'LO', 2.1e9, 'ConverterType', 'Down', 'Name', 'Mixer');
% Budget sees: -16 - (-10) = -6 dB

The IMT Table

The intermodulation table (IMT) is an MxN matrix where:

  • Rows = RF harmonic order (row 1 = order 0, row 2 = order 1, ...)

  • Columns = LO harmonic order (col 1 = order 0, col 2 = order 1, ...)

  • Values = relative power in dBc below the reference (non-negative)

  • 0 = reference level (desired output)

  • 99 = fully suppressed

Default Table
m = mixerIMT;
disp(m.IMT);
%    99    99    99
%    99     0    99
%    99    99    99

The default 3x3 table has only the desired product (RF×1, LO×1) at row 2, col 2 with value 0 (reference). Everything else is suppressed (99).

Custom IMT Table
imt = 99*ones(5,5);       % Start with everything suppressed
imt(2,2) = 0;             % RF×1, LO×1: desired output (reference)
imt(2,1) = 20;            % RF×1, LO×0: RF feedthrough at -20 dBc
imt(1,2) = 15;            % RF×0, LO×1: LO feedthrough at -15 dBc
imt(3,2) = 30;            % RF×2, LO×1: 2RF-LO spur at -30 dBc
imt(2,3) = 25;            % RF×1, LO×2: RF-2LO spur at -25 dBc
m.IMT = imt;

Gotcha: The IMT must be a real 2-D numeric matrix (class double). Setting a cell array, 3-D array, complex matrix, or non-numeric type errors with "An Intermodulation Table must be real two dimensional matrix." Ensure imt is created with standard double operations (e.g., 99*ones(M,N)).

Gotcha: IMT values must be **non-negative and <= 99** (they represent dBc below reference). Setting a negative value errors with "Value must be nonnegative." Setting a value > 99 errors with "Expected Spur table to be an array with all of the values <= 99." Using inf for "fully suppressed" also errors ("Value must be finite") — use 99 instead.

Reading the IMT Table
IMT PositionRF OrderLO OrderSpur Frequency (Down)
(1,1)00DC
(2,1)10fRF (RF feedthrough)
(1,2)01fLO (LO feedthrough)
(2,2)11fRF - fLO (desired IF)
(3,2)212·fRF - fLO
(2,3)12fRF - 2·fLO
(3,3)222·fRF - 2·fLO
Image Rejection and the IMT

The IMT models spurious products from a single RF input mixing with the LO. It does NOT model image rejection. Image rejection involves a separate signal at the image frequency (fImage = 2·fLO - fRF for low-side downconversion) producing the same IF as the desired signal. This is a different-input-frequency problem, not a same-input spur problem.

To model image rejection in a system:

  • Add a preselector or image-reject filter (rffilter or nport) before the mixer in your rfbudget chain

  • The filter's attenuation at fImage provides the image rejection

Do not attempt to represent image rejection as an IMT entry — the IMT only describes products generated from the desired RF input.

Spur Chart Visualization

m = mixerIMT('LO', 2.1e9, 'ConverterType', 'Down', 'NF', 10, 'Name', 'Mixer');
figure;
rfplot(m, 2.4e9);   % Spur chart at fRF = 2.4 GHz

rfplot(m, fRF) displays a spur chart showing all intermodulation products at the specified RF input frequency, with their relative power levels.

Gotcha: rfplot(m, fRF) takes a scalar frequency, not a vector. Passing a frequency vector errors: "Value must be a scalar."

Gotcha: rfplot(m) with no frequency argument errors: "Not enough input arguments."

Using in rfbudget

lna = amplifier('Gain', 15, 'NF', 2, 'OIP3', 35, 'Name', 'LNA');
m = mixerIMT('ReferenceInputPower', -10, 'NominalOutputPower', -16, ...
    'NF', 10, 'LO', 2.1e9, 'ConverterType', 'Down', 'Name', 'Mixer');
ifAmp = amplifier('Gain', 20, 'NF', 4, 'OIP3', 30, 'Name', 'IFAmp');

b = rfbudget([lna m ifAmp], 2.4e9, -30, 10e6);
fprintf('Total Gain: %.2f dB\n', b.TransducerGain(end));
fprintf('Output Freq: %.3f GHz\n', b.OutputFrequency(end)/1e9);

After the mixer, the output frequency changes to the IF: fIF = fRF - fLO for down-conversion.

Using in circuit

mixerIMT is a 2-port (4-terminal) element compatible with circuit:

ckt = circuit('MixerCircuit');
add(ckt, [1 2 0 0], m);
setports(ckt, [1 0], [2 0]);
s = sparameters(ckt, freq);

S2D Data Files

Load mixer characterization from an S2D file:

m = mixerIMT('FileName', 'mixer_data.s2d', 'UseDataFile', true, ...
    'LO', 2.1e9, 'ConverterType', 'Down', 'Name', 'MeasuredMixer');

OpenIF -- IF Frequency Planning

The OpenIF object finds spur-free intermediate frequencies in multiband receiver/transmitter architectures. Use it to identify open IF bands where no mixer spurs fall.

hif = OpenIF(20e6);                    % 20 MHz IF bandwidth
imt1 = [99 99 99; 99 0 99; 99 99 99]; % Default 3x3 IMT
addMixer(hif, imt1, 2.4e9, 200e6, 'low', 20e6);   % RF center, RF BW, type, IF BW
addMixer(hif, imt1, 5.2e9, 200e6, 'low', 20e6);
show(hif);                             % Graphical spur-free zone display
report(hif);                           % Command-window summary
addMixer Syntax
addMixer(hif, imt, rfCenterFreq, rfBW, mixType, ifBW)
ArgumentTypeDescription
hifOpenIFThe OpenIF object
imtMxN doubleIntermodulation table (same format as mixerIMT.IMT)
rfCenterFreqscalarRF center frequency (Hz)
rfBWscalarRF bandwidth (Hz)
mixTypechar'low' or 'high' when IFLocation='MixerOutput'; 'sum' or 'diff' when IFLocation='MixerInput'
ifBWscalarIF bandwidth for this mixer (Hz)

'low' means fIF = fRF - fLO (standard down-conversion); 'high' means fIF = fRF + fLO.

OpenIF Properties
PropertyDefaultDescription
IFBWconstructor argSystem-wide IF bandwidth (Hz)
SpurFloor99Maximum spur level to consider (dBc)
IFLocation'MixerOutput''MixerOutput' or 'MixerInput'

OpenIF complements mixerIMT: use mixerIMT + rfplot(m, fRF) to visualize spurs at a single RF frequency; use OpenIF to find spur-free IF zones across an entire multiband architecture.

Gotchas

  1. Do not set m.Gain — Although Gain is settable, rfbudget ignores it and computes gain from NominalOutputPower - ReferenceInputPower. Setting it manually has no effect on the budget and can be misleading.

  2. Gain not in constructor — mixerIMT('Gain', -6) errors. Gain cannot be passed as a constructor argument.

  3. IMT values must be 0-99 — They represent dBc below the reference (0 = reference, 99 = fully suppressed). Negative values error ("Value must be nonnegative"), values > 99 error ("values <= 99"), and inf errors ("Value must be finite"). Always use 99 for suppressed spurs, never inf.

  4. rfplot takes scalar frequency — rfplot(m, fRF) requires a single frequency, not a vector.

  5. Default conversion gain is 10 dB — NominalOutputPower(-5) - ReferenceInputPower(-15) = 10 dB. This is rarely what you want — set both explicitly.

  6. ConverterType sets Model automatically — 'Down' sets Model='demod', 'Up' sets Model='mod'.

  7. ConverterType defaults to 'Up' — If you omit ConverterType, the mixer performs up-conversion (fOut = fRF + fLO). Always set 'ConverterType', 'Down' explicitly for down-conversion receivers.

  8. IMT must be a real 2-D double matrix — Cell arrays, 3-D arrays, complex matrices, or non-numeric types error with "An Intermodulation Table must be real two dimensional matrix." Build with 99*ones(M,N) then set individual entries.

  9. Clone elements before reusing in a second rfbudget — An element object can only belong to one rfbudget at a time. Reusing it errors with "Element is already in another rfbudget." Use clone(element) to create an independent copy.

Conventions

  • Use tiledlayout/nexttile for multi-panel spur analysis figures

  • Always label spur charts with the RF input frequency

  • Set ReferenceInputPower and NominalOutputPower explicitly — do not rely on defaults

  • Use modulator for simple cascade budgets; use mixerIMT when spur analysis matters


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