Matlab Model Rf
MathWorksOfficialCreated by MathWorks
- Skill
- Guidelines
- Science and research
- BSD-2-Clause
- No issues found
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
Download the skill as a ZIP:
https://autogineer.com/agent-skills/matlab/matlab-model-rf/downloadUnzip 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
rfwriteblocks on existing files -- Always pass'ForceOverwrite', true. Without it, MATLAB opens an interactive overwrite dialog that halts unattended execution.Elements cannot be reused -- The same element object cannot appear twice in an rfbudget or circuit. Use
clone(element)for independent copies.Element Name must be a valid MATLAB identifier -- No spaces, no special characters. Use
'IFAmp'not'IF Amp'.Use
tiledlayout/nexttile-- Notsubplot. For all multi-panel figures.rfparamreturns complex, not dB -- Always use20*log10(abs(rfparam(...)))for dB magnitude.
S-Parameters and Network Parameters
sparameters(filename, Z0)is invalid -- Cannot pass reference impedance at load time. Load first, thennewref(s, Z0).rfinterp1interpolates real/imag independently -- Not magnitude and angle. Can produce artifacts near sharp resonances.Frequency alignment required for cascade/de-embed --
cascadesparamsanddeembedsparamsrequire identical frequency vectors. Alwaysrfinterp1to a common grid first.deembedsparamsalways requires 3 arguments --(sMeasured, sFixture1, sFixture2). For one-sided, pass an ideal thru for the unused side.Mixed-mode port ordering is the #1 error source --
s2sddoption 1 (default) treats ports 1,2 as positive and 3,4 as negative. Verify which option matches your VNA port numbering.snp2smpargument order: ports before impedance --snp2smp(s, portList, Z0), notsnp2smp(s, Z0, portList).
rfbudget and Elements
SignalBandwidthis required -- The 4th positional arg torfbudget. Without it, NF/IP3/SNR remain empty.Passive NF equals loss -- For
rfelement, NF should equalabs(Gain). Preferattenuatorwhich handles this automatically.nportName is positional --nport('file.s2p', 'MyName'), not name-value syntax.rffilter:
ResponseTypeis shape,FilterTypeis algorithm --rffilter('FilterType', 'Bandpass')errors. Userffilter('ResponseType', 'Bandpass').show(b)opens a GUI -- Produces no command-window output. Use properties (b.TransducerGain,b.NF) for programmatic access.
Circuit Composition
setports/setterminalscan only be called once -- Plan topology before defining terminals.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.Primitive constructors are positional --
resistor(100, 'R1'), notresistor('Resistance', 100).setterminalstakes a node vector --setterminals(ckt, [1 2]), notsetterminals(ckt, 1, 2).All txline constructors use name-value pairs only -- No positional arguments.
Amplifier Analysis
powergaingain type string must be last --powergain(s, 50, 50, 'Gt'), notpowergain(s, 'Gt', 50, 50).powergainreturns linear, not dB -- Convert with10*log10(g)(power gain uses 10x, not 20x).Gmagreturns NaN when conditionally stable -- UseGmsgat frequencies where K < 1.
Rational Fitting
rationalvsrationalfit-- Userationalfor new code (AAA). Userationalfitonly for delay extraction.Single-param fit returns plain vectors; multi-port returns cell arrays -- Always check with
iscell(result).freqresptakes Hz -- Not rad/s. Passs.Frequenciesdirectly.
System Objects (rf.*)
rf.Amplifier/rf.Mixer use 1-ohm power --
Vin = sqrt(Pin_W). This differs from rfsystem which uses 50-ohm.rf.Filter frequencies are ABSOLUTE RF --
PassFreq_bp=[2.395e9 2.405e9]means absolute GHz. Not baseband offsets.Properties locked during use -- Call
release(obj)before modifying Nontunable properties.
rfsystem
Requires rfbudget --
rfsystemtakes an rfbudget, not raw elements.close_systemneeds save flag -- Useclose_system(rfs, 0)to discard changes.IdealizedBaseband only supports amplifier/modulator/rffilter/nport -- Other elements require CircuitEnvelope.
Workflow Quick Reference
| Task | Entry Point | Details |
|---|---|---|
| Load/plot S-parameters | sparameters, rfplot, smithplot | reference/sparameters-io.md |
| Convert S/Z/Y/ABCD, mixed-mode | zparameters, s2sdd, snp2smp | reference/network-conversions.md |
| Cascade or de-embed networks | cascadesparams, deembedsparams | reference/cascade-deembed.md |
| Create rfbudget elements | amplifier, modulator, rffilter, etc. | reference/rfbudget-elements.md |
| Run cascade budget analysis | rfbudget, rfplot(b, 'Pout') | reference/rfbudget-analysis.md |
| Compose RF circuits | circuit, add, setports | reference/circuit-composition.md |
| Design matching networks | matchingnetwork, richards | reference/matching-networks.md |
| Analyze amplifier stability/gain | stabilityk, powergain, gammams | reference/amplifier-analysis.md |
| Mixer spurs and IF planning | mixerIMT, OpenIF | reference/mixer-analysis.md |
| Fit rational models, TDR | rational, stepresp, generateSPICE | reference/rational-fitting.md |
| Build SI channel models | nport + txlineWRLGC + circuit | reference/si-channel-modeling.md |
| Process complex baseband | rf.Amplifier, rf.Mixer, rf.Filter | reference/baseband-processing.md |
| Time-domain system simulation | rfsystem, Circuit Envelope | reference/system-simulation.md |
Conventions
Code Style
Use
tiledlayout/nexttilefor multi-panel figures (notsubplot)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/nexttileinstead ofsubplotdatetimeinstead ofdatenumrationalinstead ofrationalfit(unless delay extraction needed)smithplotinstead ofsmithrfplotfor 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
- ATTRIBUTION.mdAdded by AutoGineer1.0 KiB
- LICENSELicence file added by AutoGineer1.4 KiB
- SKILL.md9.8 KiB
- manifest.yaml536 B
- reference/amplifier-analysis.md9.3 KiB
- reference/amplifier-models.md2.8 KiB
- reference/amplifier-nonlinear-models.md6.2 KiB
- reference/baseband-processing.md18.5 KiB
- reference/cascade-deembed.md9.0 KiB
- reference/circle-computations.md7.3 KiB
- reference/circuit-composition.md14.1 KiB
- reference/ifft-step-response.md16.8 KiB
- reference/lumped-to-distributed.md2.7 KiB
- reference/matching-networks.md10.8 KiB
- reference/mixer-analysis.md11.0 KiB
- reference/network-conversions.md9.6 KiB
- reference/rational-fitting.md19.8 KiB
- reference/rfbudget-analysis.md8.4 KiB
- reference/rfbudget-elements.md16.8 KiB
- reference/rffilter-synthesis.md2.8 KiB
- reference/si-channel-modeling.md17.8 KiB
- reference/sparameters-io.md12.0 KiB
- reference/system-simulation.md12.9 KiB
- reference/time-domain-analysis.md3.0 KiB
- reference/transmission-lines.md2.8 KiB
reference/matching-networks.md
Impedance Matching Network Design
Design, evaluate, and optimize 1-port impedance matching networks. The matchingnetwork object and matchingNetworkDesigner app match a source impedance to a load impedance — they do not yet design 2-port (e.g., filter-style) matching. The object generates candidate topologies, ranks them by performance, and exports as circuit objects.
Creating a Matching Network
mn = matchingnetwork( ...
'SourceImpedance', 50, ...
'LoadImpedance', 75 + 20i, ...
'CenterFrequency', 2.4e9, ...
'Bandwidth', 200e6, ...
'Components', 2);Properties
| Property | Default | Description |
|---|---|---|
SourceImpedance | 50 | Source impedance (see formats below) |
LoadImpedance | 50 | Load impedance (see formats below) |
CenterFrequency | 1e9 | Design frequency (Hz) |
Bandwidth | 100e6 | Target bandwidth (Hz) |
LoadedQ | 10 | Loaded Q factor |
Components | 2 | Topology: 2, 3, 'L', 'Pi', 'Tee' |
Circuit | (auto) | Read-only array of generated circuits |
Bandwidth and LoadedQ Are Coupled
LoadedQ = CenterFrequency / Bandwidth. Setting one updates the other. If both are specified, Bandwidth takes precedence.
Components / Topology Options
| Value | Circuits Generated |
|---|---|
2 or 'L' | 2 L-section designs (series-L/shunt-C and series-C/shunt-L) |
3 | 8 three-element designs (all permutations) |
'Pi' | 4 shunt-series-shunt designs |
'Tee' | 4 series-shunt-series designs |
Gotcha: Maximum is 3 components. Components = 1 or Components = 4 error.
Impedance Source Formats
Both SourceImpedance and LoadImpedance accept:
% Scalar (constant impedance)
mn.LoadImpedance = 75 + 20i;
% S-parameter object (frequency-dependent, 1-port)
sAnt = sparameters('antenna.s1p');
mn.LoadImpedance = sAnt;
% Z-parameter or Y-parameter object
mn.LoadImpedance = zparameters(sAnt);
% Touchstone file path
mn.LoadImpedance = 'antenna.s1p';
% 1-port circuit object (must have setports called)
ckt = circuit('Load');
add(ckt, [1 0], resistor(75, 'RL'));
add(ckt, [1 0], capacitor(1e-12, 'CL'));
setports(ckt, [1 0]);
mn.LoadImpedance = ckt;
% Function handle (frequency in Hz)
mn.LoadImpedance = @(f) 50 + 30i*(f/1e9);Inspecting Candidate Designs
[topology, performance] = circuitDescriptions(mn);
disp(topology); % Component types and values for each design
disp(performance); % Pass/fail, tests failed, performance scoreThe topology table columns: circuitName, component1Type, component1Value, component2Type, component2Value, etc. Component types are "Series L", "Series C", "Shunt L", "Shunt C".
The performance table columns: circuitName, evaluationPassed ("Yes"/"No"), testsFailed, performanceScore. Designs are ranked by score (descending). The performanceScore is a weighted composite — higher is better, but the scale depends on your evaluation parameters (it is not a fixed 0–100 range). Use it for relative ranking between candidates, not as an absolute quality metric.
Use component1Type/component2Type columns in the topology table to identify which topology each auto-generated design represents (e.g., "Series L" + "Shunt C" vs "Series C" + "Shunt L").
Evaluation Parameters
Add performance goals to rank and filter designs. Only two parameter types: 'gammain' (input reflection) and 'Gt' (transducer gain).
% Require return loss below -15 dB in-band
addEvaluationParameter(mn, 'gammain', '<', -15, [2.3e9 2.5e9], 2);
% Require insertion loss above -1 dB
addEvaluationParameter(mn, 'Gt', '>', -1, [2.3e9 2.5e9], 1);
% View current evaluations
params = getEvaluationParameters(mn);
disp(params);
% Remove an evaluation by row index
clearEvaluationParameter(mn, 1);Arguments: (mn, parameter, comparison, targetdB, [fLow fHigh], weight) — all 6 are positional and required (weight is not optional).
A default automatic evaluation (Gt > -3 dB over [CenterFrequency - Bandwidth/2, CenterFrequency + Bandwidth/2]) is always present. Clear it with clearEvaluationParameter(mn, 1) if the automatic entry is at row 1.
Gotcha: Only 'gammain' and 'Gt' are supported — no S11, S21, VSWR, or other parameters.
Exporting Circuits
ckt = exportCircuits(mn); % Best-ranked circuit only
ckts = exportCircuits(mn, [1 3]); % Specific designs by indexReturns circuit objects containing inductor and capacitor elements. These can be used directly with sparameters(ckt, freq), embedded in larger circuits via add(), or cascaded.
Visualization
Frequency Response
rfplot(mn); % All designs, auto frequency range
rfplot(mn, freq); % Custom frequencies
rfplot(mn, freq, [1 3]); % Specific designsPlots two panels: input reflection coefficient (gammain) and transducer gain (Gt) in dB. Overlays evaluation goal lines.
Smith Chart
smithplot(mn); % Best design
smithplot(mn, 'CircuitIndex', 2, 'Z0', 50); % Specific designShows the impedance transformation path from source to load, tracing through each matching element in sequence (one arc per L/C component). This is the standard way to visualize each element's individual contribution to the match — no need to build intermediate circuits manually.
Gotcha: smithplot(mn) works directly on the matchingnetwork object. To plot an exported circuit's S-parameters on a Smith chart, use the S-parameter object form:
ckt = exportCircuits(mn);
s = sparameters(ckt, linspace(1e9, 3e9, 201));
smithplot(s, 1, 1); % Plot S11Do not pass the circuit object directly to smithplot — it only accepts matchingnetwork, sparameters, or numeric data.
S-Parameters
s = sparameters(mn); % Best design, auto frequency
s = sparameters(mn, freq); % Custom frequencies
s = sparameters(mn, freq, Z0); % Custom reference impedance
sArr = sparameters(mn, freq, Z0, [1 3]); % Multiple designs -> arrayThe 4-argument form sparameters(mn, freq, Z0, circuitIndex) extracts S-parameters directly without needing exportCircuits first. Use gammain(s) or powergain(s, 50, 50, 'Gt') on the result for analysis.
Richards Transformation (Lumped -> Stubs)
Convert lumped L/C matching elements to transmission line stubs. See reference/lumped-to-distributed.md for full Kuroda identity and realization details.
txCkt = richards(mn, 2.4e9); % Best design at 2.4 GHz
txCkts = richards(mn, 2.4e9, [1 2]); % Specific designsReturns circuit objects with txlineElectricalLength stub elements. Each stub has:
Z0— characteristic impedance (from original element)LineLength— electrical length in radians (pi/4 for quarter-wave)ReferenceFrequency— the operating frequency argumentTermination—'Short'for inductors,'Open'for capacitorsStubMode—'Series'or'Shunt'matching the original topology
Stub element names get a _tx suffix: C becomes C_tx, L becomes L_tx.
Tolerance Analysis
Evaluate matching network sensitivity to component value variations:
% Default 5% tolerance on all components
toleranceAnalysis(mn);
% Custom tolerances per component
toleranceAnalysis(mn, [0.05 0.02 0.10]); % 5%, 2%, 10% for each component
% Custom frequency range and specific circuit
toleranceAnalysis(mn, 0.05, linspace(0.5e9, 2.5e9, 500), 1);Arguments: (mn, tolerances, freqList, circuitIndices) — all optional after mn. Plots the nominal and perturbed responses showing the spread due to component variations.
Custom Matching Networks
Import user-designed circuits for comparison alongside auto-generated designs:
% Build a custom matching circuit
custom = circuit('MyMatch');
add(custom, [1 2], inductor(3.3e-9, 'Ls'));
add(custom, [2 0], capacitor(0.8e-12, 'Cp'));
setports(custom, [1 0], [2 0]);
% Add to matchingnetwork for evaluation
addNetwork(mn, custom); % Appears as "user_1" in circuitDescriptions
% Remove a custom network by name
deleteNetwork(mn, 'user_1');
% Suppress auto-generated designs to evaluate only custom circuits
disableAutomaticNetworks(mn);
% Re-enable auto-generated designs
enableAutomaticNetworks(mn);Custom networks appear as "user_1", "user_2", etc. in circuitDescriptions.
Gotcha: Custom circuits must be 2-port with setports called, and contain only R/L/C elements. Other element types produce -Inf performance scores.
Matching Network Designer App (R2021a+)
Interactive GUI for designing and comparing matching networks:
matchingNetworkDesigner % Launch empty
matchingNetworkDesigner(mn) % Pre-loaded with existing designThe app provides visual comparison of topologies, interactive evaluation parameter setup, and Smith chart visualization. Configure programmatically with matchingnetwork, then open in the designer for interactive exploration.
Handle Class Behavior
matchingnetwork is a handle class. These methods mutate in-place (no output argument):
addNetwork,deleteNetworkdisableAutomaticNetworks,enableAutomaticNetworks
Use copy(mn) for independent deep copies.
Gotchas
Property is
Bandwidth(lowercase 'w') — notBandWidthas some help text suggests.Components range is 2–3 only —
Components = 1orComponents = 4error.Only
'gammain'and'Gt'evaluation parameters — no S11, S21, VSWR. All 6 positional arguments are required:(mn, parameter, comparison, targetdB, [fLow fHigh], weight).Handle class —
addNetwork/deleteNetworkmutate in-place. Assigning their output errors ("too many output arguments").Custom circuits must be 2-port RLC only — other element types produce warnings and
-Infscores.Default automatic evaluation always present —
Gt > -3 dBover bandwidth. Clear explicitly if unwanted.Bandwidthtakes precedence overLoadedQwhen both are specified.smithplotonly acceptsmatchingnetworkorsparametersobjects — do not pass acircuitobject directly. For exported circuits, callsparameters(ckt, freq)first, thensmithplot(s, 1, 1).performanceScoreis relative, not absolute — use it to rank candidates against each other, not as a fixed quality metric. The scale depends on your evaluation parameters and weights.
Conventions
Use
tiledlayout/nexttilefor multi-panel matching analysis plotsShow
smithplotalongsiderfplotfor matching network analysisAlways inspect
circuitDescriptionsto compare candidates before selectingLabel axes with units (GHz, dB) and include figure titles
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