SkillAgentSearch skills...

matlab-analyze-em

S-parameters, insertion loss, fields, currents, mesh control, and solver selection for RF PCB performance validation. TRIGGER: user asks to compute S-parameters, analyze insertion/return loss, extract fields or currents, compare MoM vs FEM, or control mesh for any RF PCB component.

Install / Use

npx skills add matlab/matlab-agentic-toolkit --skill matlab-analyze-em

Installs into whichever agent you are using.

About this skill
📄

SKILL.md

Installable skill definition

Quality Score

93/100

Supported Platforms

Universal

Our assessment of matlab-analyze-em

matlab-analyze-em scores 93/100 on our quality scale, 234th of 1,199 Content & Media skills we index (top 20%).

Its SKILL.md is 19 KB long, well organised into 47 sections with 24 code examples: a thorough specification that gives an agent plenty to work with.

With 1,098 GitHub stars, it is one of the more widely adopted skills in the catalogue.

Substance
30/30
Structure
20/20
Description
15/15
Adoption
13/20
Freshness
15/15

Maintenance, license and trust

  • The repository was last updated 18 days ago, so matlab-analyze-em is actively maintained.
  • No license is declared. By default that means all rights are reserved: you can read it, but reusing or redistributing it is not clearly permitted. Ask the author before building on it commercially.
  • Its trust signals score 88/100, with 1 caution from licensing, adoption, age or documentation. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.

matlab-analyze-em compared with similar skills

All 4 of these similar skills score higher than matlab-analyze-em; compare them before choosing.

SkillScoreStarsUpdatedFormat
matlab-analyze-em (this skill)by matlab931.1k18d agoSKILL.md
Agent-Reachby Panniantong10089.8k18d agoCLAUDE.md
headroomby headroomlabs-ai10074.4ktodayCLAUDE.md
Scraplingby D4Vinci10085.4ktodayMCP Server
crawl4aiby unclecode10084.7k8d agoMCP Server

Frequently asked questions

How do I install matlab-analyze-em?
Run npx skills add matlab/matlab-agentic-toolkit --skill matlab-analyze-em. The install tabs above show the steps for each supported agent.
Which AI agents does matlab-analyze-em work with?
It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
Is matlab-analyze-em safe to use?
It declares no license and scores 88/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
Is matlab-analyze-em still maintained?
The repository was last updated 18 days ago, so matlab-analyze-em is actively maintained.

name: matlab-analyze-em description: "S-parameters, insertion loss, fields, currents, mesh control, and solver selection for RF PCB performance validation. TRIGGER: user asks to compute S-parameters, analyze insertion/return loss, extract fields or currents, compare MoM vs FEM, or control mesh for any RF PCB component. Invoke BEFORE writing sparameters() or solver code — API is non-obvious. SKIP: designing or creating components (use the specific matlab-design-pcb-* skill), material/stackup setup only (use matlab-manage-pcb-material), optimization sweeps (use matlab-optimize-pcb-design), PDN/IR-drop analysis (use matlab-analyze-pcb-pdn)." license: https://www.mathworks.com/content/dam/mathworks/license/pmrl/license.md metadata: author: MathWorks version: "1.0"

Analyzing EM Performance of RF PCB Components

When to Use

  • Extracting S-parameters from any RF PCB component (catalog or custom pcbComponent)
  • Comparing MoM vs FEM solvers or selecting the right solver for a structure
  • Using interpolating sweeps or frequencySweep objects for faster multi-frequency analysis
  • Controlling mesh density for accuracy vs speed tradeoffs
  • Visualizing E/H fields, surface currents, or charge distributions
  • Using behavioral (analytic) S-parameter models for fast estimates or optimization

When NOT to Use

  • Building or assembling custom PCB structures — use matlab-assemble-pcb-layout
  • Designing standard transmission lines or catalog objects — use matlab-design-pcb-transmission-line
  • Defining dielectric or metal materials — use matlab-manage-pcb-material
  • Cascading or connecting multiple components into circuits — use matlab-integrate-pcb-circuit
  • Importing PCB layouts from Gerber, ODB++, or Allegro — use matlab-read-pcb-layout

Typical Workflow

  1. Before: matlab-manage-pcb-material — substrate/conductor setup; then a design skill or matlab-assemble-pcb-layout — create the component
  2. This skill: Extract S-parameters, visualize fields and currents, verify performance
  3. After: matlab-optimize-pcb-design — tune dimensions if specs not met → matlab-integrate-pcb-circuit — cascade into larger network → matlab-write-pcb-layout — export Gerber

Quick Reference

| Task | Code | |------|------| | S-parameters (MoM) | sp = sparameters(obj, freq, 'SweepOption', 'interp') | | S-params with port Z0 | sp = sparameters(obj, freq, 50, 'SweepOption', 'interp') | | Interpolating sweep | sp = sparameters(obj, freq, 50, 'SweepOption', 'interp') | | Interp with gradient | sp = sparameters(obj, freq, 50, 'SweepOption', 'interpWithGrad') | | Plot S-params | rfplot(sp) or rfplot(sp, [2 1], 1) | | Current distribution | current(obj, fc) | | Charge distribution | charge(obj, fc) | | Feed current | feedCurrent(obj, freq) | | E/H fields | [e, h] = EHfields(obj, fc, points) | | Set mesh | mesh(obj, 'MaxEdgeLength', val) | | Memory estimate | memoryEstimate(obj, fc) | | Switch to FEM solver | pcb.SolverType = 'FEM' | | FEM boundary condition | s = solver(pcb); s.BoundaryCondition = 'absorbing' | | Frequency sweep object | fsweep = frequencySweep; sp = sparameters(obj, freq, 'SweepOption', fsweep) | | Rational model from sweep | rmodel = getRationalModel(fsweep) | | Discover methods | methods(obj) |

S-Parameter Extraction

The sparameters function is the primary analysis method for all RF PCB components.

Basic Usage

obj = design(couplerBranchline, 5e9);
freq = linspace(1e9, 10e9, 101);
sp = sparameters(obj, freq, 'SweepOption', 'interp');
figure;
rfplot(sp);

Specifying Port Impedance

sp = sparameters(obj, freq, 50, 'SweepOption', 'interp');   % 50-ohm reference
sp = sparameters(obj, freq, 75, 'SweepOption', 'interp');   % 75-ohm reference

Plotting Specific S-Parameters

rfplot(sp, [2 1], 1);              % Plot S21 only
rfplot(sp, [1 1], 1);              % Plot S11 only
rfplot(sp, 2:4, 1);               % Plot S21, S31, S41 vs port 1

Extracting Numeric Data

sp = sparameters(obj, freq, 'SweepOption', 'interp');
S21_dB = 20*log10(abs(squeeze(sp.Parameters(2,1,:))));
S11_dB = 20*log10(abs(squeeze(sp.Parameters(1,1,:))));

Solver Selection

RF PCB Toolbox supports two electromagnetic solvers:

| Solver | Property Value | Best For | |--------|---------------|----------| | Method of Moments (MoM) | 'MoM' (default) | Planar structures, open radiators | | Finite Element Method (FEM) | 'FEM' | Shielded catalog elements; also available on pcbComponent via SolverType |

Switching to FEM

FEM is available via pcbComponent:

pcb = pcbComponent(couplerBranchline);
pcb.SolverType = 'FEM';
sp_fem = sparameters(pcb, freq);

FEM Boundary Condition Configuration

After setting SolverType to 'FEM', retrieve the solver object via solver() to configure boundary conditions:

pcb = pcbComponent(catalogObj);
pcb.SolverType = 'FEM';

s = solver(pcb);                          % Returns em.solvers.fem.FEM object
s.BoundaryCondition = 'absorbing';        % or 'perfectly-matched-layer' (default)

| Boundary Condition | Value | Use Case | |--------------------|-------|----------| | Perfectly Matched Layer (PML) | 'perfectly-matched-layer' (default) | Open radiating structures, antennas | | Absorbing | 'absorbing' | Shielded enclosures, waveguide ports |

Gotcha: solver(comp, 'SolverType', 'FEM') errors with "Too many input arguments." SolverType is a property of pcbComponent, not an argument to solver(). BoundaryCondition is a property of the returned FEM solver object, not of the component.

FEM Prerequisites

The FEM solver (introduced R2025a) requires two dependencies:

  1. Integro-Differential Modeling Framework for MATLAB (IDMF) — Install via Home > Add-Ons > search "Integro-Differential Modeling Framework for MATLAB". Verify with matlab.addons.installedAddons.
  2. Windows Subsystem for Linux (WSL) — Required on Windows. Install via wsl --install from an elevated PowerShell prompt. Verify with wsl --status.

If WSL is available, the FEM solver can be used when designing custom structures via pcbComponent. For shielded catalog elements, FEM is used automatically.

Firewall note: Windows Defender may block the PostgreSQL server used by IDMF (<matlabroot>\sys\postgresql\win64\PostgreSQL\bin\postgres.exe). If FEM solves hang on first use, inform the user of this potential cause and defer to them on what action to take per their IT/security policies. Do not modify firewall settings autonomously.

WSL Memory Tuning

WSL is allocated only 50% of system RAM by default. Large FEM problems may fail with out-of-memory errors. If the user hits OOM during an FEM solve, inform them that WSL memory can be increased by editing C:/Users/%UserProfile%/.wslconfig:

[wsl2]
memory=48GB
swap=8GB

Followed by wsl --shutdown and restart-service LxssManager (elevated PowerShell). Values should be adjusted based on system specs. This may require IT involvement — ask the user to make this change manually and resume when ready. Do not create or modify .wslconfig autonomously.

FEM-Only Properties

When SolverType='FEM', additional properties become available on pcbComponent:

| Property | Purpose | |----------|---------| | Connector | Attach an RFConnector object for coaxial feed modeling (default: 50-ohm, InnerRadius=0.5mm, OuterRadius=1.5mm) | | IsShielded | Add metal shielding box around the structure (dimensions match ground plane) |

FEM Constraints

  • No mode impedance extraction: getZEven/getZOdd are not available with the FEM solver. Use S-parameters only for shielded comparisons.
  • PEC required: FEM requires Conductivity=Inf (PEC). Finite conductivity metals (e.g., Copper) will error. For shielded vs unshielded comparisons, use PEC for both.
  • Connector spacing: The RFConnector outer radius (default 1.5 mm) must fit between adjacent ports. If port spacing is tight, increase Spacing/GroundPlaneWidth or reduce OuterRadius on the connector.

Comparing Solvers

obj = design(couplerBranchline, 5e9);
freq = linspace(1e9, 5e9, 21);

sp_mom = sparameters(obj, freq, 'SweepOption', 'interp');

pcb = pcbComponent(obj);
pcb.SolverType = 'FEM';
sp_fem = sparameters(pcb, freq);  % FEM: interp not applicable

figure;
rfplot(sp_mom); hold on;
rfplot(sp_fem, '--');
legend('MoM', 'FEM');

Interpolating Sweep

For faster multi-frequency analysis, use interpolating sweep instead of discrete point-by-point solves. This is significantly faster, especially for large structures.

Basic Interpolation

freq = linspace(4.5e9, 5.5e9, 101);
sp = sparameters(obj, freq, 50, 'SweepOption', 'interp');

Interpolation with Gradient

More accurate interpolation using gradient information:

freq = [4.5e9, 5.5e9];  % Only need start/end — solver picks internal points
sp = sparameters(obj, freq, 50, 'SweepOption', 'interpWithGrad');

When to Use Interpolation

| Scenario | Recommendation | |----------|---------------| | Narrowband (< 2:1 BW) | 'interpWithGrad' — fastest, accurate | | Wideband (> 2:1 BW) | 'interp' — stable over wide range | | Debugging / single freq | No sweep option (discrete) | | Resonant structures | Discrete or fine 'interp' grid |

frequencySweep Object (R2025a)

For finer control over interpolation-based sweeps, use the frequencySweep object. It exposes error tolerance, iteration limits, and rational fitting — useful when the default 'SweepOption' settings are not sufficient.

fsweep = frequencySweep;
fsweep.SweepType = "interp";        % "interp" (default) | "interpWithGrad"
fsweep.ErrTol = -80;                % dB, default -80
fsweep.NumFreqs = 100;              % points to discretize frequency range, default 100
fsweep.NumIters = 25;               % max fitting iterations, default 25

freq = linspace(1e9, 10e9, 200);
sp = sparameters(comp, freq, 'SweepOption', fsweep);

% Extract rational fitting model after the sweep
rmodel = getRationalModel(fsweep);

| Property | Default | Description | |----------|---------|-------------| | SweepType | "interp" | Interpolation type; "interpWithGrad" uses gradient info | | ErrTol | -80 dB | Max error tolerance between fitting iterations | | NumFreqs | 100 | Number of points to discretize frequency range | | NumIters | 25 | Maximum number of fitting iterations |

Mesh Control

Mesh density directly affects accuracy and computation time.

Setting Maximum Edge Length

Rule of thumb: MaxEdgeLength ≤ λ/8 at the highest frequency.

fc = 10e9;
lambda = 3e8 / fc;
mesh(obj, 'MaxEdgeLength', lambda/8);

Viewing the Mesh

figure;
mesh(obj);                              % Visualize default mesh
figure;
mesh(obj, 'MaxEdgeLength', 1e-3);       % Visualize refined mesh

Mesh Configuration

Switch between automatic and manual meshing:

meshconfig(obj, 'manual');
mesh(obj, 'MaxEdgeLength', 0.5e-3, 'MinEdgeLength', 0.1e-3);

meshconfig(obj, 'auto');   % Revert to automatic meshing

Pre-Solve Checkpoint: Inspect Mesh and Memory

Catalog components generate dense auto-meshes that can dominate runtime even with interpolating sweep. Always inspect before committing to a full solve:

fc = 10e9;
memoryEstimate(obj, fc, 'RetainMesh', true);  % Estimate RAM; retain mesh for inspection
mesh(obj);                                     % Visualize — check if overly dense

% If too dense or memory too high, coarsen
lambda = physconst('LightSpeed') / fc;
mesh(obj, 'MaxEdgeLength', lambda/6);          % Relax from default
memoryEstimate(obj, fc, 'RetainMesh', true);   % Re-check after coarsening

The 'RetainMesh', true option keeps the generated mesh attached to the object so you can visualize it immediately. Without it, the mesh is discarded af

Truncated for display — read the full file on GitHub.

Related Skills

View on GitHub
GitHub Stars1.1k
CategoryContent
Updated18d ago
Forks134

Languages

MATLAB

Trust signals

88/100

From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.

1 medium