matlab-design-reflectarray
This skill designs reflectarray antennas and reconfigurable intelligent surfaces in MATLAB by building parameterized unit cells with pcbStack, characterizing reflection phase responses through infinite array analysis, synthesizing required aperture phase distributions, and verifying beam patterns via pattern multiplication. Use it when designing phase-controlled periodic surfaces for beam steering, RIS applications, or intelligent reflecting surfaces.
git clone --depth 1 https://github.com/matlab/matlab-agentic-toolkit /tmp/matlab-design-reflectarray && cp -r /tmp/matlab-design-reflectarray/skills-catalog/rf-and-mixed-signal/matlab-design-reflectarray ~/.claude/skills/matlab-design-reflectarraySKILL.md
# Reflectarray and RIS Design Skill
You are an expert RF and antenna engineer assisting a professional engineer with reflectarray and reconfigurable intelligent surface (RIS) design. Use MATLAB Antenna Toolbox (`pcbStack` + `infiniteArray` + `planeWaveExcitation`) to design unit cells, characterize phase response, synthesize aperture distributions, and verify beam patterns.
## When to Use
- User wants to design a reflectarray antenna
- User wants to design a reconfigurable intelligent surface (RIS)
- User wants to characterize unit cell reflection phase (S-curve)
- User wants to synthesize an aperture phase distribution for beam steering
- User asks about pattern multiplication for a periodic surface
- User wants to build a conformalArray with unique unit cell elements
## When NOT to Use
- User wants a curved reflector (parabolic, Cassegrain) — use `matlab-design-reflector-antenna`
- User wants a simple PCB antenna without periodic cells — use `matlab-design-pcb-antenna`
- User wants plane wave scattering analysis only — use `matlab-analyze-plane-wave`
- User wants an infinite array without reflectarray context — use `matlab-design-array`
## Core Workflow
1. **Parse the request** -- Identify the operating frequency, aperture size, beam direction, unit cell topology, substrate, f/D ratio, and whether it is a fixed reflectarray or reconfigurable RIS (with phase quantization bits).
2. **Design the unit cell** -- Build a parameterized `pcbStack` with a variable geometric parameter (patch size, slot length, rotation angle).
3. **Characterize the S-curve** -- Sweep the geometric parameter using `planeWaveExcitation` + `infiniteArray` + `EHfields` to extract reflection phase and magnitude at each step.
4. **Synthesize the aperture phase** -- Compute the required reflection phase at each element position given the feed location and desired beam direction.
5. **Map phase to geometry** -- Invert the S-curve to convert required phases to physical dimensions. For RIS, quantize to discrete states.
6. **Build the geometry** -- Construct a `conformalArray` with unique `pcbStack` elements at each position for visualization.
7. **Verify with pattern multiplication** -- Compute the element pattern from a representative unit cell, combine with the array factor, and display using `patternCustom`.
## Unit Cell Design with pcbStack
A reflectarray unit cell is a `pcbStack` with three layers: **patch (metal) + substrate (dielectric) + ground (metal)**.
```matlab
f0 = 5.8e9;
c0 = physconst("LightSpeed");
lambda = c0 / f0;
cellSize = 0.5 * lambda;
Lp = 8e-3;
subHeight = 1.524e-3;
sub = dielectric(Name="RO4003C", EpsilonR=3.55, LossTangent=0.0027, Thickness=subHeight);
boardGnd = antenna.Rectangle(Length=cellSize, Width=cellSize);
patch = antenna.Rectangle(Length=Lp, Width=Lp);
uc = pcbStack;
uc.BoardShape = boardGnd;
uc.BoardThickness = subHeight;
uc.Layers = {patch, sub, boardGnd};
uc.FeedLocations = [Lp/4, 0, 1, 3]; % offset feed for proper excitation
figure;
show(uc);
```
**Feed location:** Use `[Lp/4, 0, 1, 3]` -- the feed is offset from patch center by `Lp/4` in x, connecting layer 1 (patch) to layer 3 (ground). The offset ensures proper excitation of the dominant patch mode.
### Critical Constraint: 3-Layer Limit
**`infiniteArray` only supports pcbStack with exactly 3 layers** (metal-dielectric-metal). Multi-layer stacks throw: *"Multilayer Substrate is not supported for Infinite arrays."*
### Layer Numbering
Layer 1: patch (metal), Layer 2: substrate (dielectric), Layer 3: ground (metal). `FeedLocations = [x y sigLayer gndLayer]` references these indices.
### Shape Objects for Metal Patterns
All shapes are in the `antenna` namespace. Use boolean operations for complex geometries:
```matlab
% Cross-shaped patch
crossPatch = antenna.Rectangle(Length=armLen, Width=armWid) + ...
antenna.Rectangle(Length=armWid, Width=armLen);
% Ring patch
ring = antenna.Circle(Radius=Ro) - antenna.Circle(Radius=Ri);
% Slotted patch
slotted = antenna.Rectangle(Length=Lp, Width=Wp) - antenna.Rectangle(Length=Ls, Width=Ws);
```
### Substrate Selection
| Material | EpsilonR | LossTangent | Use Case |
|----------|----------|-------------|----------|
| Custom `"RO4003C"` | 3.55 | 0.0027 | Recommended for reflectarrays |
| `"Teflon"` | 2.1 | 0.0002 | Low-loss, moderate phase range |
| `"TMM3"` | 3.45 | 0.002 | Higher permittivity, wider phase range |
| `"FR4"` | 4.8 | 0.026 | Prototyping only (high loss) |
Use `dielectric(Name="RO4003C", EpsilonR=3.55, LossTangent=0.0027, Thickness=h)` for custom materials not in the built-in catalog.
## Phase Characterization (S-Curve)
### Recommended: planeWaveExcitation + EHfields
This method uses `planeWaveExcitation` to illuminate the unit cell with a plane wave and `EHfields` to extract the patch-scattered field. The periodic Green's function in `infiniteArray` accounts for mutual coupling between elements.
**Important:** `EHfields` returns only the field scattered by the patch currents — the ground plane specular reflection is not included separately (it is part of the background medium). The magnitude therefore peaks at resonance (maximum patch re-radiation), which differs from a classical reflection coefficient that dips at resonance. However, the **relative phase variation** across patch sizes is correct for reflectarray design because the ground plane contribution is spatially constant and cancels when computing inter-element phase differences. The `AF` scaling factor (`4*pi*cellSize^2/lambda^2`) is a real scalar that does not affect phase; magnitude is normalized afterward.
```matlab
f0 = 5.8e9;
c0 = physconst("LightSpeed");
lambda = c0 / f0;
k0 = 2*pi / lambda;
cellSize = 0.5 * lambda;
subHeight = 1.524e-3;
epsR = 3.55;
tanD = 0.0027;
sub = dielectric(Name="RO4003C", EpsilonR=epsR, LossTangent=tanD, Thickness=subHeight);
boardGnd = antenna.Rectangle(Length=cellSize, Width=cellSize);
% Nominal resonant patch size (starti>
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.