matlab-design-pcb-antenna
This MATLAB skill designs PCB antennas using the Antenna Toolbox pcbStack function to create multi-layer stackups with custom metal patterns, boolean shape operations, and various feed types (probe, edge, aperture). Use it when designing or fabricating printed antennas from scratch, converting catalog antennas to PCB format, adding custom elements like slots or vias, or generating Gerber files for manufacturing.
git clone --depth 1 https://github.com/matlab/matlab-agentic-toolkit /tmp/matlab-design-pcb-antenna && cp -r /tmp/matlab-design-pcb-antenna/skills-catalog/rf-and-mixed-signal/matlab-design-pcb-antenna ~/.claude/skills/matlab-design-pcb-antennaSKILL.md
# PCB Antenna Design Skill
You are an expert RF and antenna engineer assisting a professional engineer with PCB antenna design. Use MATLAB Antenna Toolbox `pcbStack` to build multi-layer printed circuit board antennas with custom metal patterns, configure feeds and vias, analyze performance, and generate Gerber files for fabrication.
## When to Use
- User wants to design a PCB antenna or printed antenna from scratch
- User wants to build a multi-layer antenna stackup
- User wants to convert a catalog antenna (patchMicrostrip, pifa) to pcbStack
- User wants to add custom metal patterns, slots, or parasitic elements to a PCB
- User asks about probe feed, edge feed, or aperture-coupled feed on a PCB
- User wants to export Gerber files for antenna fabrication
- User wants to add via stitching or shorting vias
## When NOT to Use
- User wants a simple catalog antenna analysis — use `matlab-design-antenna`
- User wants a matching network — use `matlab-design-matching-network`
- User wants a reflectarray with unit cells — use `matlab-design-reflectarray`
- User wants to design a curved reflector — use `matlab-design-reflector-antenna`
## Core Workflow
1. **Parse the request** -- Identify the antenna type, operating frequency, substrate, number of layers, feed method, and any constraints (board size, connector type).
2. **Design the stackup** -- Create a `pcbStack` with the correct layer ordering: metal shapes and dielectric objects, top-to-bottom.
3. **Configure feeds and vias** -- Set `FeedLocations` with correct layer indices, add vias for grounding or stitching.
4. **Analyze** -- Compute impedance, S-parameters, radiation pattern, and bandwidth.
5. **Export** -- Generate Gerber fabrication files with connector footprints.
## Layer Stack Construction
This is the most error-prone step. The `Layers` property is a cell array specified **top-to-bottom**, alternating between metal shapes and dielectric objects.
```matlab
% 3-layer: patch on FR4 with ground plane
subHeight = 1.6e-3;
sub = dielectric("FR4");
p = pcbStack;
p.BoardShape = antenna.Rectangle(Length=60e-3, Width=60e-3);
p.BoardThickness = subHeight; % MUST be set BEFORE Layers
p.Layers = {patch, sub, ground}; % {metal(1), diel(2), metal(3)}
```
### Critical Rules
1. **Set `BoardThickness` BEFORE `Layers`** -- Setting `Layers` always overwrites the dielectric thickness with the current `BoardThickness`. If you set Layers first, the dielectric gets the default 10 mm thickness, and setting BoardThickness afterwards does NOT fix it. To suppress the warning, also set `sub.Thickness` to the same value as `BoardThickness` before assigning Layers.
2. **Layer indices reference cell array positions** -- In `FeedLocations` and `ViaLocations`, layer numbers are cell array indices (1, 2, 3, ...), not metal-only indices. In `{metal, diel, metal}`, the metals are at indices 1 and 3.
3. **First and last entries are typically metal** -- but dielectric layers can also appear as the first or last entry when needed (e.g., radome above the top patch, or substrate beneath the bottom feed layer). Example: `{diel, patch, diel, slottedGround, diel, feedLine}`.
4. **`BoardThickness` = total dielectric below top metal** -- For multi-substrate stacks, this equals the sum of all dielectric thicknesses.
### 3-Layer Stack (Most Common)
```matlab
% {topMetal(1), dielectric(2), bottomMetal(3)}
p.Layers = {patch, sub, ground};
p.FeedLocations = [x, y, 1, 3]; % sig=1(top), gnd=3(bottom)
```
### 2-Layer Stack (Air Dielectric)
When only two metal layers are specified with no dielectric object, the stack assumes air as the dielectric between them:
```matlab
% {topMetal(1), bottomMetal(2)} -- air dielectric assumed
p.Layers = {radiator, ground};
p.FeedLocations = [x, y, 1, 2]; % sig=1(top), gnd=2(bottom)
```
### 5-Layer Stack (Aperture-Coupled)
```matlab
% {radiator(1), upperSub(2), slottedGround(3), lowerSub(4), feedLine(5)}
p.BoardThickness = upperSubHeight + lowerSubHeight;
p.Layers = {radiator, upperSub, slottedGround, lowerSub, feedLine};
p.FeedLocations = [x, y, 5, 3]; % sig=5(feedLine), gnd=3(ground)
```
### Substrate Materials
| Material | EpsilonR | LossTangent | Use Case |
|----------|----------|-------------|----------|
| `"FR4"` | 4.8 | 0.026 | Prototyping, low cost |
| Custom `"RO4003C"` | 3.55 | 0.0027 | High-frequency, low loss |
| `"Teflon"` | 2.1 | 0.0002 | Very low loss |
| `"Air"` | 1.0 | 0 | 2-layer stacks with physical spacer |
For materials not in the built-in catalog, create a custom dielectric:
```matlab
sub = dielectric(Name="RO4003C", EpsilonR=3.55, LossTangent=0.0027, Thickness=h);
```
## Shape Operations for Metal Patterns
All shapes are in the `antenna` namespace. Build complex metal patterns using boolean operations.
### Available Shapes
| Shape | Key Properties |
|-------|---------------|
| `antenna.Rectangle` | `Length`, `Width`, `Center`, `NumPoints` |
| `antenna.Circle` | `Radius`, `Center`, `NumPoints` |
| `antenna.Ellipse` | `MajorAxis`, `MinorAxis`, `Center` |
| `antenna.Polygon` | `Vertices` (N-by-3 matrix) |
| `antenna.Triangle` | `InputType` ("SSS"/"SAS"/"ASA"), `Side`, `Angle` |
### Boolean Operations
```matlab
% Union: combine shapes
patchWithFeed = patch + feedLine;
% Subtraction: cut slots, notches, holes
gndWithSlot = ground - slot;
eNotch = patch - notch1 - notch2;
% Intersection: overlap region
overlap = shape1 & shape2;
```
### Geometric Transforms
```matlab
% Translate
shifted = translate(shape, [dx, dy, 0]);
% Rotate (requires axis definition, or use rotateZ convenience)
rotated = rotate(shape, angleDeg, [0 0 0], [0 0 1]);
rotated = rotateZ(shape, angleDeg);
% Mirror (for symmetric geometries — fractals, bowties, balanced structures)
mirrored = mirrorX(copy(shape)); % mirror across Y-axis
mirrored = mirrorY(copy(shape)); % mirror across X-axis
% Copy (duplicate before transforming to preserve original)
shapeCopy = copy(shape);
% Scale
bigger = scale(shape, fa>
Analyze AMS waveform data using Mixed-Signal Blockset utilities: phase noise measurement, clock jitter, anti-aliased resampling, timing measurements, lock time, INL/DNL, ADC/DAC calibration, HSpice import. Use when analyzing time-domain voltage from PLL/VCO/clock simulations, measuring phase noise from variable-step solver output, computing jitter, or resampling non-uniform data.
Analyze data using MATLAB. Use when the task involves tables, timetables, time-series data, numeric arrays, sensor matrices, or gridded data — including but not limited to exploring, filtering, sorting, cleaning, transforming, aggregating, smoothing, padding, trimming, and answering questions about data. MATLAB provides extensive, easy-to-use built-in functions for these workflows with no additional products required.
Analyze the effective toolbox file set to produce a Dependency Manifest — classify all transitive dependencies as included, product, add-on, or external-unresolved, then present resolution options with tradeoffs. Use after matlab-define-toolbox-api when the spec is approved.
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).
Analyze antennas installed on electrically large conducting platforms using MATLAB Antenna Toolbox. Loads platform geometry from STL/STEP/IGES, installs antenna elements, selects electromagnetic solvers (MoM-PO, FMM, MoM), and computes patterns, impedance, coupling, and efficiency. Use when the user wants to model an antenna on a vehicle, aircraft, ship, satellite, or other large structure.
PDN DC voltage/current analysis, IR drop, design rule checking, and multi-net batch analysis on imported PCB layouts. TRIGGER: user asks about power integrity, PDN analysis, IR drop, voltage distribution, current density, power nets, or design rule checking on a PCB. Invoke BEFORE writing code — the PDN API chain is specialized and non-obvious. SKIP: importing a PCB file (use matlab-read-pcb-layout), EM field/S-parameter extraction (use matlab-analyze-em), material/stackup setup only (use matlab-manage-pcb-material), transmission line design (use matlab-design-pcb-txline).
Calculate and visualize monostatic and bistatic radar cross section (RCS) using MATLAB Antenna Toolbox. Computes RCS of platforms, antennas, and arrays with PO, MoM, and FMM solvers, supporting HH/VV/HV/VH polarization, GPU acceleration, and near-field observation. Use when the user wants to compute, plot, or analyze radar cross section.