Generated banner for Matlab Write Pcb Layout
Generated logo for Matlab Write Pcb Layout

Matlab Write Pcb Layout

MathWorksOfficialCreated by MathWorks

  • Skill
  • Tool integration
  • Software development
  • BSD-2-Clause
  • No issues found

From the author

Export pcbComponent designs to Gerber files with RF connectors and fab service formatting for PCB manufacturing. TRIGGER: user asks to export a PCB design to Gerber, generate manufacturing files, or write out a pcbComponent for fabrication. Invoke BEFORE writing export code — gerberWrite signature (pcbComponent, connectors, filename) is non-obvious. SKIP: importing/reading PCB files (use matlab-read-pcb-layout), building PCB geometry (use matlab-assemble-pcb-layout), EM analysis (use matlab-analyze-em), material/stackup setup (use matlab-manage-pcb-material).
— the description by MathWorks

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides the interface for exporting MATLAB-based PCB designs into manufacturing-ready Gerber files. It enables users to configure fabrication service settings, attach standard RF connectors (such as SMA, SMB, and MMCX), and generate the necessary drill and layer files for PCB production. The skill is designed to bridge the gap between electromagnetic design and physical fabrication by handling the specific formatting requirements of various PCB service providers.

What it does

  • Generates Gerber and drill files from pcbComponent objects.
  • Provides a catalog of over 25 standard RF connector types for PCB integration.
  • Supports specific output formatting for major fabrication services like OSH Park and Seeed Studio.
  • Allows customization of export parameters including board margins, solder mask layers, and coordinate units.
  • Enables automated connector dimension tuning for FEM-based pcbComponent designs.

When to use it

  • When you have a completed pcbComponent design ready for physical fabrication.
  • When you need to attach specific RF connectors to your board layout.
  • When you need to generate manufacturing files tailored to a specific fabrication house.
  • When you need to export a design package that includes copper, mask, silkscreen, and drill data.

Advantages

  • Streamlines the transition from RF simulation to physical manufacturing.
  • Reduces manual configuration errors by using built-in fabrication service writers.
  • Ensures consistent connector footprints and drill patterns.
  • Provides programmatic control over complex export settings like coordinate precision and units.

Usage examples

“Export my pcbComponent design to Gerber files for OSH Park.”
The agent will use the OSHParkWriter to generate the required Gerber and drill files, applying the default settings for that service.
“How do I add SMA connectors to my PCB export?”
The agent will demonstrate how to define the SMA connector objects and pass them as a cell array to the gerberWrite function.
“Customize my Gerber export to use millimeters and a specific filename.”
The agent will show how to configure the PCBServices writer object properties, such as Filename and CoordUnits, before calling the export function.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/matlab/matlab-write-pcb-layout/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip matlab-write-pcb-layout.zip -d .agents/skills

Documentation by MathWorks

Writing PCB Layouts to Manufacturing Files

When to Use

  • Exporting a pcbComponent or pcbStack design to Gerber manufacturing files

  • Selecting and configuring RF connectors (SMA, SMB, MMCX, etc.) for PCB export

  • Formatting output for specific fabrication services (OSH Park, Seeed, Advanced Circuits)

  • Attaching RFConnector objects to catalog components for shielded analysis

  • Generating a complete manufacturing package from a MATLAB RF design

When NOT to Use

  • Importing Gerber files into MATLAB — use matlab-read-pcb-layout

  • Building the PCB design itself — use matlab-assemble-pcb-layout or the designing skills

  • Running EM analysis — use matlab-analyze-em

Typical Workflow

  1. Before: A design skill or matlab-assemble-pcb-layout — create the pcbComponent; matlab-analyze-em — validate performance; matlab-optimize-pcb-design — tune if needed

  2. This skill: Export to Gerber with connectors and fab formatting

Quick Reference

TaskCode
Export Gerber files[A,g] = gerberWrite(pcb, W, {C1,C2})
SMA connectorC = PCBConnectors.SMA_Cinch
Edge-launch SMAC = PCBConnectors.SMAEdge_Samtec
PCB service writerW = PCBServices.OSHParkWriter
Customize writerW.Filename = 'name'; W.CoordUnits = 'mm'
RF connector objectrc = RFConnector
Design connector for PCBrc = design(RFConnector, pcb)

gerberWrite — Export to Manufacturing

The gerberWrite function generates manufacturing files from a pcbComponent.

Basic Export
p = pcbComponent;   % Your designed component
W = PCBServices.OSHParkWriter;
W.Filename = 'my_design';          % Controls output zip/folder name (default: 'untitled')
C1 = PCBConnectors.SMA_Cinch;
C2 = PCBConnectors.SMA_Cinch;

[A, outputPath] = gerberWrite(p, W, {C1, C2});
Output

gerberWrite produces a folder of Gerber and drill files:

  • Top/bottom copper layers

  • Solder mask layers

  • Silkscreen layers

  • Drill files

  • Board outline

The A output is a PCBWriter object with export metadata. outputPath is the path to the generated files.

PCBWriter Object

The PCBWriter object controls export settings.

Properties
PropertyDescription
DesignStruct containing the PCB design data
WriterThe PCB service writer (output format)
ConnectorCell array of connector objects
UseDefaultConnectorUse default connector if none specified
ComponentBoundaryLineWidthOutline line width
PCBMarginExtra board margin around component (m)
Soldermask'both', 'top', 'bottom', or 'none'
SolderpasteLogical — generate solderpaste layer
FontFont for text on silkscreen

PCBConnectors — Connector Catalog

Attach standard RF connectors to your exported board.

Available Connectors (25 Built-in Types)
CategoryConnectors
SMA 5-PadSMA, SMA_Cinch, SMA_Multicomp
SMA Edge-LaunchSMAEdge, SMAEdge_Cinch, SMAEdge_Samtec, SMAEdge_Amphenol, SMAEdge_Linx
SMB/SMCSMB_Johnson, SMB_Pasternack, SMC_Pasternack, SMCEdge_Pasternack
MMCXMMCX_Cinch, MMCX_Samtec
IPX/U.FLIPX_Jack_Lighthorse, IPX_Plug_Lighthorse, UFL_Hirose
Coaxial CableCoax_RG11, Coax_RG58, Coax_RG59, Coax_RG174
Semi-RigidSemi_020, Semi_034, Semi_047, Semi_118

Access via PCBConnectors.<type>. All connectors have common properties: Type, Mfg, Part, Annotation, Impedance (default: 50 ohm), Datasheet, Purchase.

5-pad properties: TotalSize, GroundPadSize, SignalPadDiameter, PinHoleDiameter, IsolationRing, VerticalGroundStrips

Edge-launch properties: GroundPadSize, GroundSeparation, GroundPadIsolation, SignalPadSize, SignalGap, SignalLineWidth, EdgeLocation ('north'|'south'|'east'|'west'), ExtendBoardProfile, FillGroundSide

Coax properties: PinDiameter, DielectricDiameter, ShieldDiameter, AddThermals, ThermalsDiameter, ThermalsBridgeWidth

Connectors are placed at feed locations during Gerber export. They define pad footprints and drill patterns.

PCBServices — Fabrication Service Writers

Writers configure output for specific fabrication services.

Available Services (5 Built-in Writers)
ServiceDescription
PCBServices.GerbLookWriterGerbLook online viewer
PCBServices.ZofZWriterZofZ 3-D Gerber viewer
PCBServices.AdvancedCircuitsWriterAdvanced Circuits manufacturing
PCBServices.SeeedWriterSeeed Studio manufacturing
PCBServices.OSHParkWriterOSH Park manufacturing

Each writer formats Gerber files according to the fab house's naming and layer conventions.

Key PCBServices properties: Filename, CoordUnits ('in'/'mm'), CoordPrecision, CreateArchiveFile, DefaultViaDiameter, UseExcellon, BoardProfileFile, SameExtensionForGerberFiles, PostWriteFcn, Files

% Customize a service writer
w = PCBServices.AdvancedCircuitsWriter;
w.Filename = 'my_antenna';
w.CoordUnits = 'mm';
w.CoordPrecision = [3 4];

RF Connectors

RFConnector models coaxial connectors (SMA, SMB, etc.) that attach to PCB structures.

rc = RFConnector;
rc.InnerRadius  = 5e-4;      % Center pin radius
rc.OuterRadius  = 1.5e-3;    % Outer conductor radius
rc.PinLength    = 3e-3;      % Pin insertion depth
rc.PinFootprint = 'Taper';   % 'Taper' or 'Circular'
rc.EpsilonR     = 1.7341;    % Dielectric fill permittivity
rc.Impedance    = 50;        % Characteristic impedance
Attaching to a Catalog Object

Attaching a Connector to a catalog object (e.g., microstripLine) requires IsShielded = true:

m = microstripLine;
m.IsShielded = true;          % Required before setting Connector
m.Connector = RFConnector;
show(m);
Design for a pcbComponent

design() auto-tunes connector dimensions to match a PCB object. This requires an FEM-based pcbComponent — catalog objects like microstripLine do not support FEM:

pcb = pcbComponent;           % Must be pcbComponent with SolverType='FEM'
pcb.SolverType = 'FEM';
rc = design(RFConnector, pcb);

Complete Design-to-Manufacturing Workflow

%% Design a filter
f = design(filterCoupledLine, 3e9);

%% Analyze
freq = linspace(1e9, 5e9, 101);
sp = sparameters(f, freq, 'SweepOption', 'interp');
rfplot(sp);

%% Export for manufacturing (convert to pcbComponent first)
pcb = pcbComponent(f);
W = PCBServices.OSHParkWriter;
C1 = PCBConnectors.SMA_Cinch;
C2 = PCBConnectors.SMA_Cinch;
[A, gPath] = gerberWrite(pcb, W, {C1, C2});

Pitfalls

  1. Connector compatibility: Not all connectors work with all board thicknesses. SMA edge-launch connectors assume standard substrate heights. Check connector footprint dimensions match your board.

  2. Gerber aperture limitations: Complex curved geometries may be approximated with polygons in Gerber format. Very fine features may lose resolution during export — check minimum feature size for your target fab service.

  3. Multiple connectors need cell array: When passing multiple connectors to gerberWrite, wrap them in a cell array: gerberWrite(pcb, W, {C1, C2}). An object array [C1, C2] will error.

  4. gerberWrite requires pcbComponent or pcbStack: gerberWrite does not work on catalog objects (e.g., microstripLine, filterHairpin). Convert to pcbComponent first if needed.

  5. Connector requires IsShielded on catalog objects. Setting obj.Connector = RFConnector on a catalog object (microstripLine, etc.) will error with "SolverType property must be set to 'FEM'" unless obj.IsShielded = true is set first. Catalog objects do not support FEM directly — use IsShielded = true for MoM shielded mode. design(RFConnector, obj) only works with pcbComponent objects that have SolverType='FEM'.

  6. IsShielded + finite conductivity conflict. Setting IsShielded = true activates an internal FEM-like solver path. If you also set Conductor = metal("Copper") (finite conductivity), you will get "FEM solver does not support finite conductivity. Set conductivity of conductor to Inf." Leave Conductor at the default (PEC) when using IsShielded = true or Connector.

  7. gerberWrite on pcbcascade results. pcbcascade returns a pcbComponent. This can be passed directly to gerberWrite. However, verify the port count and connector count match — pcbcascade merges ports and removes connected ports, so the surviving port count may differ from the input components.

  8. IsShielded switches solver to FEM — affects sweep options. Setting IsShielded = true changes the internal solver to FEM. The 'SweepOption', 'interp' interpolated sweep is designed for MoM and may not be available or behave differently with FEM. Run S-parameter analysis before adding IsShielded for export, or use a discrete frequency sweep with FEM.

  • matlab-read-pcb-layout — Import layouts from Gerber, ODB++, and Allegro

  • matlab-assemble-pcb-layout — Building custom PCB structures from shapes

  • matlab-analyze-em — Running EM analysis before export


Copyright 2026 The MathWorks, Inc.

Files

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.

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-write-pcb-layout · 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-write-pcb-layout.zip