matlab-optimize-pcb-design
Optimize RF PCB dimensions for bandwidth, return loss, or area via patternsearch and surrogateopt with constraints. TRIGGER: user asks to optimize an RF PCB component for performance (bandwidth, return loss, insertion loss, area) or apply constraints to a design.
Install / Use
npx skills add matlab/matlab-agentic-toolkit --skill matlab-optimize-pcb-designInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
Content & MediaSupported Platforms
Our assessment of matlab-optimize-pcb-design
matlab-optimize-pcb-design scores 93/100 on our quality scale, 243rd of 1,199 Content & Media skills we index (top 21%).
Its SKILL.md is 17 KB long, well organised into 30 sections with 17 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.
Maintenance, license and trust
- The repository was last updated 18 days ago, so matlab-optimize-pcb-design 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-optimize-pcb-design compared with similar skills
All 4 of these similar skills score higher than matlab-optimize-pcb-design; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| matlab-optimize-pcb-design (this skill)by matlab | 93 | 1.1k | 18d ago | SKILL.md |
| siyuanby siyuan-note | 100 | 46.6k | today | MCP Server |
| algorithmic-artby anthropics | 100 | 177.9k | 11d ago | SKILL.md |
| pptxby anthropics | 100 | 177.9k | 11d ago | SKILL.md |
| designby nextlevelbuilder | 100 | 130.2k | 12d ago | SKILL.md |
Frequently asked questions
- How do I install matlab-optimize-pcb-design?
- Run
npx skills add matlab/matlab-agentic-toolkit --skill matlab-optimize-pcb-design. The install tabs above show the steps for each supported agent. - Which AI agents does matlab-optimize-pcb-design 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-optimize-pcb-design 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-optimize-pcb-design still maintained?
- The repository was last updated 18 days ago, so matlab-optimize-pcb-design is actively maintained.
Skill content
View source on GitHubname: matlab-optimize-pcb-design description: "Optimize RF PCB dimensions for bandwidth, return loss, or area via patternsearch and surrogateopt with constraints. TRIGGER: user asks to optimize an RF PCB component for performance (bandwidth, return loss, insertion loss, area) or apply constraints to a design. Invoke BEFORE writing optimization code — RF PCB Toolbox has a built-in optimize() function that differs from generic fmincon/ga approaches. SKIP: designing a component from scratch without an optimization objective (use the specific matlab-design-pcb-* skill), EM analysis without optimization (use matlab-analyze-em), material/stackup setup only (use matlab-manage-pcb-material)." license: https://www.mathworks.com/content/dam/mathworks/license/pmrl/license.md metadata: author: MathWorks version: "1.0"
Optimizing RF PCB Designs
Critical: Always Use optimize() First
The RF PCB Toolbox provides a built-in optimize() function that handles all standard optimization scenarios. Always use it as the first approach — do NOT write manual optimization loops with patternsearch, surrogateopt, fmincon, or ga called directly unless optimize() is demonstrably insufficient for the specific problem.
When to Use
- Tuning filter, coupler, or splitter dimensions for return loss, bandwidth, or area
- Running
optimize()on catalog objects with bounds and constraints - Using SADEA/TR-SADEA, patternsearch, or surrogateopt via the
optimize()interface - Defining custom objective functions over S-parameter responses
When NOT to Use
- Designing components from scratch — use
matlab-design-pcb-filter,matlab-design-pcb-coupler, etc. first, then optimize - Running EM analysis without optimization — use
matlab-analyze-em - Parameter sweeps without an objective — just loop over
sparameterscalls directly - Antenna-only optimization without PCB context — use Antenna Toolbox docs
Typical Workflow
- Before: A design skill (
matlab-design-pcb-filter,matlab-design-pcb-transmission-line, etc.) — create the initial component;matlab-analyze-em— baseline S-parameters - This skill: Define objective, bounds, constraints; run
optimize() - After:
matlab-analyze-em— validate optimized design →matlab-integrate-pcb-circuit— cascade into system →matlab-write-pcb-layout— export Gerber
Quick Reference
| Task | Code |
|------|------|
| Design at frequency | obj = design(ObjectType, fc) |
| Optimize | optObj = optimize(obj, freq, objective, props, bounds, solver) |
| With constraints | optimize(..., 'Constraints', constraints) |
| With options | optimize(..., 'OptimizerOptions', opts) |
Algorithm Overview
| Algorithm | Source | Best For | Typical Time |
|---|---|---|---|
| sadea | Antenna Toolbox (SADEA) | Default global search, few EM evaluations | 5--30 min |
| trsadea | Antenna Toolbox (TR-SADEA) | Trust-region variant, better local refinement | 5--30 min |
| patternsearch | Global Optimization Toolbox | Derivative-free, smooth/noisy EM objectives, fine-tuning | 2--15 min |
| surrogateopt | Global Optimization Toolbox | Expensive black-box functions, many variables, global optimum | 10--60 min |
- Start with SADEA -- it requires no additional toolbox beyond Antenna Toolbox and handles most RF/PCB optimization problems well.
- Use
patternsearchfor fine-tuning -- after SADEA finds a good region, refine with patternsearch starting from the SADEA result. surrogateoptfor expensive models -- builds a surrogate model and is more sample-efficient when each EM solve is costly.
Timing and Practical Considerations
- MoM simulation per evaluation: 2--30 seconds for simple components, minutes for high-order filters
- Behavioral mode: Use
pcbElement(comp, Behavioral=true)for fast analytical evaluations during optimization sweeps - Iteration budget: Set
MaxIterationsto 20--50 when running interactively to stay responsive; use 100--200 for batch runs - Parallel computing: Set
UseParallel=trueif Parallel Computing Toolbox is available for significant speedup with patternsearch and surrogateopt
design() — Initial Sizing
The design function sizes any catalog component for a target frequency:
ws = design(wilkinsonSplitter, 3e9);
bl = design(couplerBranchline, 5e9);
fh = design(filterHairpin, 2.4e9);
ms = design(microstripLine, 3e9);
This produces a starting point for subsequent optimization. All geometric parameters are auto-computed for the target frequency.
optimize() Syntax
optObj = optimize(obj, freq, objective, properties, bounds, solver, ...
'Constraints', constraints, 'OptimizerOptions', opts)
| Argument | Type | Description |
|----------|------|-------------|
| obj | Object | Catalog object (initial design) |
| freq | Scalar or vector | Single frequency or frequency vector for optimization |
| objective | String | Built-in or custom objective function name |
| properties | Cell array | Property names to vary |
| bounds | 2-element cell | {[lower1 lower2 ...]; [upper1 upper2 ...]} |
| solver | String | 'patternsearch', 'surrogateopt', 'sadea', or 'trsadea' |
| constraints | Struct | S-parameter constraints (optional NV pair) |
| opts | optimoptions | Optimizer options object created with optimoptions() |
Built-in Objectives
| Objective String | Minimizes/Maximizes |
|-----------------|---------------------|
| "minimizeArea" | Minimizes board area |
| "maximizeBandwidth" | Maximizes -10 dB return loss bandwidth |
| "maximizeReturnLoss" | Maximizes worst-case return loss |
| "minimizeBandwidth" | Narrows the passband |
Example: Minimize Area with Constraints
obj = design(wilkinsonSplitter, 3e9);
props = {'SplitLineLength', 'SplitLineWidth', 'Resistance', ...
'PortLineLength', 'GroundPlaneWidth'};
bounds = {[10e-3 1e-3 50 2e-3 10e-3]; % Lower bounds
[50e-3 8e-3 100 20e-3 50e-3]}; % Upper bounds (cell array!)
constraints.S11 = '<-10';
constraints.S21 = '>-4';
constraints.S22 = '<-10';
constraints.S12 = '>-4';
optObj = optimize(obj, 3e9, "minimizeArea", props, bounds, ...
"patternsearch", 'Constraints', constraints);
show(optObj);
sp = sparameters(optObj, linspace(1e9, 5e9, 51), 'SweepOption', 'interp');
rfplot(sp);
% Verify area from shapes
s = shapes(optObj); % Returns struct of shapes by layer
boardArea = area(s.GroundPlane);
fprintf('Optimized board area: %.2f mm²\n', boardArea * 1e6);
Querying Area After Optimization
For catalog objects, use shapes() to extract the individual layer shapes, then area():
s = shapes(optObj); % Catalog object → struct with named shapes
boardArea = area(s.GroundPlane); % Area of the board outline shape
For pcbComponent, shapes are in the Layers property:
pcb = pcbComponent(optObj);
boardArea = area(pcb.BoardShape);
Example: Maximize Return Loss for Hairpin Filter
f = design(filterHairpin, 3e9);
props = {'CoupledLineLength', 'CoupledLineWidth', 'CoupledLineSpacing'};
bounds = {[5e-3 0.5e-3 0.1e-3];
[40e-3 5e-3 2e-3]};
optF = optimize(f, 3e9, "maximizeReturnLoss", props, bounds, "patternsearch");
show(optF);
S-Parameter Constraints
Constraints use string format '<threshold' or '>threshold' (in dB):
constraints.S11 = '<-15'; % S11 below -15 dB
constraints.S21 = '>-1'; % S21 above -1 dB (low insertion loss)
constraints.S31 = '<-20'; % Isolation below -20 dB
Any S-parameter index can be constrained. The optimizer evaluates constraints across the entire frequency vector.
Custom Objective Functions
For objectives beyond the built-in set, provide a function handle:
% Objective function signature: cost = objFcn(obj, freq)
function cost = myObjective(obj, freq)
sp = sparameters(obj, freq, 'SweepOption', 'interp');
S21 = squeeze(sp.Parameters(2,1,:));
S11 = squeeze(sp.Parameters(1,1,:));
% Minimize worst-case insertion loss while maintaining match
cost = -min(20*log10(abs(S21))); % Negative because we maximize |S21|
end
optObj = optimize(obj, fc, @myObjective, props, bounds, "patternsearch");
Surrogate-Based Optimization
For expensive EM solves, surrogate optimization builds a model and is more sample-efficient:
opts = optimoptions('surrogateopt', 'MaxFunctionEvaluations', 50);
optObj = optimize(obj, 3e9, "maximizeReturnLoss", props, bounds, ...
"surrogateopt", 'OptimizerOptions', opts);
Solver Options
The OptimizerOptions NV pair takes an optimoptions object for the chosen solver:
opts = optimoptions('patternsearch', 'MaxFunctionEvaluations', 100, 'Display', 'off');
optObj = optimize(obj, fc, objective, props, bounds, 'patternsearch', ...
'OptimizerOptions', opts);
Available solvers: 'patternsearch', 'surrogateopt', 'sadea', 'trsadea'.
For sadea/trsadea, pass a struct instead of an optimoptions object:
opts = struct('MaxIterations', 50, 'UseParallel', false);
optObj = optimize(obj, fc, objective, props, bounds, 'sadea', ...
'OptimizerOptions', opts);
Nested Property Optimization
Optimize nested properties using dot notation:
% Optimize substrate thickness along with width
optObj = optimize(ml, 2.4e9, 'maximizeReturnLoss', ...
{'Width', 'Substrate.Thickness'}, ...
{0.001 0.5e-3; 0.01 3e-3}, 'sadea');
Decision: optimize() vs Manual Loop
Always use optimize(). It wraps all four solvers (sadea, trsadea, patternsearch, surrogateopt) internally. There is no performance or capability advantage to calling these solvers directly. The only scenario where direct solver usage is justified is a non-S-parameter, non-EM objective function that optimize() cannot express (extremely rare).
Optimization Workflow
- Design initial geometry:
obj = design(Type, fc) - Select properties to vary: Choose 3-6 most impactful dimensions
- Set reasonable bounds: ±50% of initial values is a good starting range
- Define constraints: Ensure feasibility (S11 < -10 dB at minimum)
- Choose solver: Start with
'sadea'; use'patternsearch'for refinement - Run optimize():
optObj = optimize(obj, freq, objective, props, bounds, solver) - Validate: Check optimized design meets specs across full band
Antenna Objects with optimize()
The same optimize() function works on antenna objects with antenna-specific objectives:
| Objective | Description |
|---|---|
| 'maximizeGain' | Maximize antenna gain at target frequency |
| 'frontToBackRatio' | Maximize front-to-back lobe ratio |
| 'maximizeSLL' | Maximize sidelobe level suppression |
ant = design(patchMicrostrip, 2.4e9);
optAnt = optimize(ant, 2.4e9, 'maximizeGain', ...
{'Length', 'Width'}, {[0.02 0.02]; [0.06 0.06]}, 'sadea', ...
'OptimizerOptions', struct('MaxIterations', 100));
pattern(optAnt, 2.4e9);
These objectives are for antenna objects only. RF PCB catalog objects use the objectives in the Built-in Objectives table above.
Fallback: Direct Solver Usage (Last Resort)
Direct solver calls are almost never needed — optimize() already wraps patternsearch, surrogateopt, sadea, and trsadea. Only bypass optimize() for non-EM objectives it cannot express (e.g., multi-objective Pareto front via paretosearch).
% Extremely rare: multi-objective Pareto (not supported by optimize())
objFcn = @(x) [emObjective(obj, x, freq); thermalObjective(obj, x)];
[xopt, fval] = paretosearch(objFcn, nVars, [], [], [], [], lb, ub);
Design Iteration Patterns
Variable Naming Conventions
Use these names consistently across optimization scripts and iterative design loops:
sub % dielectric substrate
cond % metal conductor
ml % microstripLine
sl % stripLine
cpw % coplanarWave
Truncated for display — read the full file on GitHub.
Related Skills
siyuan
46.6kAn open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
algorithmic-art
177.9kCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems.
pptx
177.9kUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an em…
design
130.2kComprehensive design skill: brand identity, design tokens, UI styling, logo generation (55 styles, Gemini, Atlas Cloud, or MuAPI AI), corporate identity program (50 deliverables, CIP mockups), HTML presentations (Chart.js), banner design (22 styles, social/ads/web/print), icon design (15 styles, SVG…
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
